| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Sah::Filter::perl::Str::maybe_eval; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
366030
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
75
|
|
|
4
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
331
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
7
|
|
|
|
|
|
|
our $DATE = '2024-02-06'; # DATE |
|
8
|
|
|
|
|
|
|
our $DIST = 'Sah-Schemas-Str'; # DIST |
|
9
|
|
|
|
|
|
|
our $VERSION = '0.018'; # VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub meta { |
|
12
|
|
|
|
|
|
|
+{ |
|
13
|
0
|
|
|
0
|
0
|
|
v => 1, |
|
14
|
|
|
|
|
|
|
summary => "Eval string if in the form of 'sub { ... }'", |
|
15
|
|
|
|
|
|
|
might_fail => 1, |
|
16
|
|
|
|
|
|
|
args => { |
|
17
|
|
|
|
|
|
|
# XXX namespace |
|
18
|
|
|
|
|
|
|
# XXX use strict? |
|
19
|
|
|
|
|
|
|
# XXX use warnings? |
|
20
|
|
|
|
|
|
|
}, |
|
21
|
|
|
|
|
|
|
}; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub filter { |
|
25
|
0
|
|
|
0
|
0
|
|
my %fargs = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $dt = $fargs{data_term}; |
|
28
|
0
|
|
0
|
|
|
|
my $gen_args = $fargs{args} // {}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $res = {}; |
|
31
|
0
|
|
|
|
|
|
$res->{expr_filter} = join( |
|
32
|
|
|
|
|
|
|
"", |
|
33
|
|
|
|
|
|
|
"do {", ( |
|
34
|
|
|
|
|
|
|
"my \$tmp = $dt; ", |
|
35
|
|
|
|
|
|
|
"if (ref(\$tmp) || \$tmp !~ qr/\\Asub\\s*\\{.*\\}\\z/s) { ", ( |
|
36
|
|
|
|
|
|
|
"[undef, \$tmp] "), # pass through |
|
37
|
|
|
|
|
|
|
"} else { ", ( |
|
38
|
|
|
|
|
|
|
"my \$code = eval qq(package main; \$tmp); if (\$@) { [\"Error in compiling code: \$@\", \$tmp] } else { [undef, \$code] } ", |
|
39
|
|
|
|
|
|
|
"}"), |
|
40
|
|
|
|
|
|
|
), |
|
41
|
|
|
|
|
|
|
"}", |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$res; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
|
48
|
|
|
|
|
|
|
# ABSTRACT: Eval string if in the form of 'sub { ... }' |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |