| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Sah::Filter::perl::Str::maybe_convert_to_re; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
284550
|
use 5.010001; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
71
|
|
|
5
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
264
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
8
|
|
|
|
|
|
|
our $DATE = '2024-02-06'; # DATE |
|
9
|
|
|
|
|
|
|
our $DIST = 'Sah-Schemas-Str'; # DIST |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.018'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub meta { |
|
13
|
|
|
|
|
|
|
+{ |
|
14
|
0
|
|
|
0
|
0
|
|
v => 1, |
|
15
|
|
|
|
|
|
|
summary => 'Convert string to regex if delimited by /.../ or qr(...)', |
|
16
|
|
|
|
|
|
|
might_fail => 1, |
|
17
|
|
|
|
|
|
|
args => { |
|
18
|
|
|
|
|
|
|
# XXX delimiter |
|
19
|
|
|
|
|
|
|
# XXX allowed modifiers |
|
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 (\$tmp =~ m!\\A(?:/.*/|qr\\(.*\\))(?:[ims]*)\\z!s) { my \$re = eval(substr(\$tmp, 0, 2) eq 'qr' ? \$tmp : \"qr\$tmp\"); if (\$@) { [\"Invalid regex: \$@\", \$tmp] } else { [undef, \$re] } } ", |
|
36
|
|
|
|
|
|
|
" else { [undef, \$tmp] } ", |
|
37
|
|
|
|
|
|
|
"}", |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$res; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
|
44
|
|
|
|
|
|
|
# ABSTRACT: Convert string to regex if string is delimited by /.../ or qr(...) |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |