| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ath; |
|
2
|
1
|
|
|
1
|
|
103770
|
use strict; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
30
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
32
|
|
|
4
|
1
|
|
|
1
|
|
530
|
use Math::Calc::Parser; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
58
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use Encode (); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
160
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
|
7
|
|
|
|
|
|
|
my ($bignum, $bigrat); |
|
8
|
|
|
|
|
|
|
sub import { |
|
9
|
|
|
|
|
|
|
my $class = shift; |
|
10
|
|
|
|
|
|
|
foreach my $opt (@_) { |
|
11
|
|
|
|
|
|
|
$bignum = 1 if $opt eq '-bignum'; |
|
12
|
|
|
|
|
|
|
$bigrat = 1 if $opt eq '-bigrat'; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
sub unimport { $bignum = $bigrat = undef } |
|
16
|
|
|
|
|
|
|
use Filter::Simple sub { |
|
17
|
4
|
|
|
|
|
183
|
my $expr = quotemeta Encode::decode 'UTF-8', "$_", Encode::FB_CROAK | Encode::LEAVE_SRC; |
|
18
|
4
|
50
|
|
|
|
394
|
my $opts = $bigrat ? 'bigrat => 1' : $bignum ? 'bignum => 1' : ''; |
|
|
|
50
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
15
|
$_ = "use utf8; print Math::Calc::Parser->new($opts)->evaluate(qq{$expr}), qq{\n};" |
|
20
|
1
|
|
|
1
|
|
589
|
}; |
|
|
1
|
|
|
|
|
15418
|
|
|
|
1
|
|
|
|
|
10
|
|
|
21
|
|
|
|
|
|
|
1; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=encoding utf8 |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
ath - Evaluate mathematical expressions in a compact one-liner |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$ perl -Math -e'2+2' |
|
32
|
|
|
|
|
|
|
$ perl -Math -e'5!' |
|
33
|
|
|
|
|
|
|
$ perl -Math -e'round e^(i*pi)' |
|
34
|
|
|
|
|
|
|
$ perl -Math -e'log 5rand' |
|
35
|
|
|
|
|
|
|
$ perl -Math -e'2π' |
|
36
|
|
|
|
|
|
|
$ perl -Math=-bignum -e'30!' |
|
37
|
|
|
|
|
|
|
$ perl -Math=-bigrat -e'3/9' |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
A source filter that parses and evaluates the source code as a mathematical |
|
42
|
|
|
|
|
|
|
expression using L, and prints the result. The C<-bignum> |
|
43
|
|
|
|
|
|
|
or C<-bigrat> flags may be passed to activate the corresponding option. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 BUGS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Report any issues on the public bugtracker. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Dan Book, C |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copyright 2015, Dan Book. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under |
|
58
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L |