line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Evo::Lib::PP; |
2
|
19
|
|
|
19
|
|
8982
|
use Evo '-Export *; Carp croak'; |
|
19
|
|
|
|
|
46
|
|
|
19
|
|
|
|
|
114
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
sub eval_want : Export { |
5
|
19
|
|
|
19
|
0
|
2331
|
my ($want, $fn) = (shift, pop); |
6
|
19
|
100
|
|
|
|
82
|
if (!defined $want) { |
|
|
100
|
|
|
|
|
|
7
|
5
|
100
|
|
|
|
10
|
eval { $fn->(@_); 1 } or return; |
|
5
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
15
|
|
8
|
2
|
|
|
1
|
|
15
|
return sub { }; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
elsif (!$want) { |
11
|
10
|
|
|
|
|
19
|
my $res; |
12
|
10
|
100
|
|
|
|
21
|
eval { $res = $fn->(@_); 1 } or return; |
|
10
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
45
|
|
13
|
8
|
|
|
12
|
|
41
|
return sub {$res}; |
|
12
|
|
|
|
|
540
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
else { |
16
|
4
|
|
|
|
|
11
|
my @res; |
17
|
4
|
100
|
|
|
|
9
|
eval { @res = $fn->(@_); 1 } or return; |
|
4
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
27
|
|
18
|
3
|
|
|
3
|
|
21
|
return sub {@res}; |
|
3
|
|
|
|
|
487
|
|
19
|
|
|
|
|
|
|
} |
20
|
19
|
|
|
19
|
|
152
|
} |
|
19
|
|
|
|
|
45
|
|
|
19
|
|
|
|
|
135
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub try : prototype(&$;$) : Export { |
23
|
0
|
|
|
0
|
0
|
0
|
my ($try, $catch, $fin) = @_; |
24
|
0
|
|
|
|
|
0
|
my $call = eval_want wantarray, $try; |
25
|
0
|
0
|
0
|
|
|
0
|
$call = eval_want wantarray, my $e = $@, $catch if !$call && $catch; |
26
|
0
|
0
|
|
|
|
0
|
if ($call) { # in normal way we are here, so separate this branch to avoid copying $@ before fin |
27
|
0
|
0
|
|
|
|
0
|
$fin->() if $fin; |
28
|
0
|
|
|
|
|
0
|
return $call->(); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
0
|
$e = $@; |
31
|
0
|
0
|
|
|
|
0
|
$fin->() if $fin; |
32
|
0
|
|
|
|
|
0
|
die $e; |
33
|
19
|
|
|
19
|
|
4781
|
} |
|
19
|
|
|
|
|
46
|
|
|
19
|
|
|
|
|
77
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub uniq : Export { |
36
|
2
|
|
|
2
|
0
|
406
|
my %seen; |
37
|
2
|
|
|
|
|
5
|
return grep { !$seen{$_}++ } @_; |
|
8
|
|
|
|
|
28
|
|
38
|
19
|
|
|
19
|
|
2779
|
} |
|
19
|
|
|
|
|
46
|
|
|
19
|
|
|
|
|
75
|
|
39
|
|
|
|
|
|
|
|
40
|
17
|
50
|
|
17
|
0
|
84
|
sub strict_opts ($hash, @other) : Export { |
|
17
|
|
|
|
|
178
|
|
|
17
|
|
|
|
|
45
|
|
|
17
|
|
|
|
|
29
|
|
41
|
17
|
100
|
100
|
|
|
261
|
croak 'Usage strict_opts($hash, qw(key1 key2))' |
|
|
|
100
|
|
|
|
|
42
|
|
|
|
|
|
|
. 'or strict_opts($hash, ["key1", "key2"], $level)' |
43
|
|
|
|
|
|
|
if !@other || (ref $other[0]) && @other > 2; |
44
|
15
|
|
|
|
|
27
|
my ($level, @keys); |
45
|
15
|
100
|
|
|
|
37
|
if (ref $other[0]) { |
46
|
14
|
|
|
|
|
30
|
@keys = (shift @other)->@*; |
47
|
14
|
100
|
|
|
|
35
|
$level = @other ? shift(@other) : 1; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
1
|
|
|
|
|
3
|
@keys = @other; |
51
|
1
|
|
|
|
|
2
|
$level = 1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
15
|
|
|
|
|
40
|
my %opts = %$hash; |
55
|
15
|
|
|
|
|
33
|
my @opts = map { delete $opts{$_} } @keys; |
|
30
|
|
|
|
|
71
|
|
56
|
15
|
100
|
|
|
|
46
|
if (my @remaining = keys %opts) { |
57
|
2
|
|
|
|
|
4
|
local $Carp::CarpLevel = $level; |
58
|
2
|
|
|
|
|
224
|
croak "Unknown options: ", join ',', @remaining; |
59
|
|
|
|
|
|
|
} |
60
|
13
|
|
|
|
|
51
|
@opts; |
61
|
19
|
|
|
19
|
|
6017
|
} |
|
19
|
|
|
|
|
45
|
|
|
19
|
|
|
|
|
79
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |