line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Way; |
2
|
2
|
|
|
2
|
|
30371
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
819
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
517
|
|
|
2
|
|
|
|
|
10
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ match /; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub match { |
11
|
16
|
|
|
16
|
1
|
206
|
my ($target, $cond, $and) = @_; |
12
|
|
|
|
|
|
|
|
13
|
16
|
100
|
|
|
|
35
|
if ( ref($cond) eq 'ARRAY' ) { |
14
|
9
|
100
|
|
|
|
12
|
if ($and) { |
15
|
2
|
|
|
|
|
3
|
for my $c (@{$cond}) { |
|
2
|
|
|
|
|
5
|
|
16
|
6
|
100
|
|
|
|
7
|
return unless _match($target, $c); |
17
|
|
|
|
|
|
|
} |
18
|
1
|
|
|
|
|
12
|
return 1; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
7
|
|
|
|
|
5
|
for my $c (@{$cond}) { |
|
7
|
|
|
|
|
15
|
|
22
|
11
|
100
|
|
|
|
13
|
return 1 if _match($target, $c); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
7
|
100
|
|
|
|
9
|
return 1 if _match($target, $cond); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
14
|
return; # not match |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _match { |
34
|
24
|
|
|
24
|
|
25
|
my ($target, $cond) = @_; |
35
|
|
|
|
|
|
|
|
36
|
24
|
100
|
100
|
|
|
82
|
if ( !ref($cond) || ref($cond) eq 'Regexp' ) { |
|
|
50
|
|
|
|
|
|
37
|
19
|
100
|
|
|
|
158
|
return 1 if $target =~ m!$cond!; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ( ref($cond) eq 'CODE' ) { |
40
|
5
|
100
|
|
|
|
10
|
return 1 if $cond->($target); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
10
|
|
|
|
|
36
|
return; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |