line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Reverse::Converter::Regexp; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Convert parts to Regular Expression simply |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
609
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
305
|
use Scalar::Util qw(blessed); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
7
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.143'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub Convert{ |
11
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
12
|
0
|
|
|
|
|
|
my $parts = shift; |
13
|
0
|
|
|
|
|
|
my @temps; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
foreach my $pat (@{$parts}){ |
|
0
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my @pre = @{$pat->pre}; |
|
0
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my @post = @{$pat->post}; |
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
@pre = map{blessed($_)?$_->as_string:$_}@pre; |
|
0
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
@post= map{blessed($_)?$_->as_string:$_}@post; |
|
0
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $pretxt = join '',@pre; |
22
|
0
|
|
|
|
|
|
my $posttxt = join '',@post; |
23
|
0
|
0
|
|
|
|
|
$pretxt .= '' if $pretxt; |
24
|
0
|
0
|
|
|
|
|
$posttxt = ''.$posttxt if $posttxt; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
0
|
|
|
|
if( $pretxt eq '' || $posttxt eq '' ){ |
27
|
0
|
|
|
|
|
|
push(@temps,qr!\Q$pretxt\E(.+)\Q$posttxt\E!); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else{ |
30
|
0
|
|
|
|
|
|
push(@temps,qr!\Q$pretxt\E(.+?)\Q$posttxt\E!); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return \@temps; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |