line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package match::simple; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
16130
|
use 5.006001; |
|
2
|
|
|
|
|
4
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
30
|
|
5
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
46
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
783
|
use Exporter::Tiny; |
|
2
|
|
|
|
|
4266
|
|
|
2
|
|
|
|
|
11
|
|
8
|
2
|
|
|
2
|
|
202
|
use List::Util 1.33 qw(any); |
|
2
|
|
|
|
|
49
|
|
|
2
|
|
|
|
|
152
|
|
9
|
2
|
|
|
2
|
|
7
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
134
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
2
|
|
|
2
|
|
4
|
$match::simple::AUTHORITY = 'cpan:TOBYINK'; |
13
|
2
|
|
|
|
|
338
|
$match::simple::VERSION = '0.010'; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw( Exporter::Tiny ); |
17
|
|
|
|
|
|
|
our @EXPORT = qw( M ); |
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw( match ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $xs; |
21
|
|
|
|
|
|
|
unless (($ENV{MATCH_SIMPLE_IMPLEMENTATION}||'') =~ /pp/i) |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
eval { |
24
|
|
|
|
|
|
|
require match::simple::XS; |
25
|
|
|
|
|
|
|
match::simple::XS->VERSION(0.001); # minimum |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Unless we're a development version... |
28
|
|
|
|
|
|
|
# Avoid using an unstable version of ::XS |
29
|
|
|
|
|
|
|
unless (match::simple->VERSION =~ /_/) |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
die if match::simple::XS->VERSION =~ /_/; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$xs = match::simple::XS->can('match'); |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
eval($xs ? <<'XS' : <<'PP'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub IMPLEMENTATION () { "XS" } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
*match = *match::simple::XS::match; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
XS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub IMPLEMENTATION () { "PP" } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub match |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
no warnings qw(uninitialized numeric); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my ($a, $b) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return(!defined $a) if !defined($b); |
55
|
|
|
|
|
|
|
return($a eq $b) if !ref($b); |
56
|
|
|
|
|
|
|
return($a =~ $b) if ref($b) eq q(Regexp); |
57
|
|
|
|
|
|
|
return do{ local $_ = $a; !!$b->($a) } if ref($b) eq q(CODE); |
58
|
|
|
|
|
|
|
return any { match($a, $_) } @$b if ref($b) eq q(ARRAY); |
59
|
|
|
|
|
|
|
return !!$b->check($a) if blessed($b) && $b->isa("Type::Tiny"); |
60
|
|
|
|
|
|
|
return !!$b->MATCH($a, 1) if blessed($b) && $b->can("MATCH"); |
61
|
|
|
|
|
|
|
return eval 'no warnings; !!($a~~$b)' if blessed($b) && $] >= 5.010 && do { require overload; overload::Method($b, "~~") }; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
require Carp; |
64
|
|
|
|
|
|
|
Carp::croak("match::simple cannot match anything against: $b"); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
PP |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _generate_M |
70
|
|
|
|
|
|
|
{ |
71
|
2
|
|
|
2
|
|
893
|
require Sub::Infix; |
72
|
2
|
|
|
|
|
1377
|
&Sub::Infix::infix(\&match); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |