line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
20272
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
33
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
3
|
|
|
|
|
|
|
package Data::InputMonster::Util; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$Data::InputMonster::Util::VERSION = '0.010'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
# ABSTRACT: handy routines for use with the input monster |
8
|
1
|
|
|
1
|
|
735
|
use Sub::Exporter::Util qw(curry_method); |
|
1
|
|
|
|
|
22350
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
5
|
use Sub::Exporter -setup => { |
11
|
|
|
|
|
|
|
exports => { |
12
|
|
|
|
|
|
|
dig => curry_method, |
13
|
|
|
|
|
|
|
}, |
14
|
1
|
|
|
1
|
|
248
|
}; |
|
1
|
|
|
|
|
3
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub dig { |
19
|
5
|
|
|
5
|
1
|
452
|
my ($self, $locator) = @_; |
20
|
|
|
|
|
|
|
|
21
|
5
|
50
|
|
|
|
14
|
Carp::confess("no locator given") unless defined $locator; |
22
|
|
|
|
|
|
|
|
23
|
5
|
100
|
|
|
|
15
|
$locator = [ $locator ] unless ref $locator; |
24
|
|
|
|
|
|
|
|
25
|
5
|
50
|
|
|
|
23
|
if (ref $locator eq 'CODE') { |
|
|
50
|
|
|
|
|
|
26
|
0
|
|
|
0
|
|
0
|
return sub { $locator->($_[1]) }; |
|
0
|
|
|
|
|
0
|
|
27
|
|
|
|
|
|
|
} elsif (ref $locator eq 'ARRAY') { |
28
|
|
|
|
|
|
|
return sub { |
29
|
5
|
|
|
5
|
|
11
|
my ($monster, $input) = @_; |
30
|
5
|
|
|
|
|
7
|
my $next = $input; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
11
|
for my $k (@$locator) { |
33
|
14
|
100
|
|
|
|
42
|
return unless my $ref = ref $next; |
34
|
13
|
50
|
66
|
|
|
60
|
return unless $ref and (($ref eq 'ARRAY') or ($ref eq 'HASH')); |
|
|
|
33
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
13
|
100
|
100
|
|
|
77
|
return if $ref eq 'ARRAY' and $k !~ /\A-?\d+\z/; |
37
|
12
|
100
|
|
|
|
30
|
$next = $next->[ $k ] if $ref eq 'ARRAY'; |
38
|
12
|
100
|
|
|
|
33
|
$next = $next->{ $k } if $ref eq 'HASH'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
17
|
return $next; |
42
|
5
|
|
|
|
|
34
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
Carp::confess("locator must be either a code or array reference"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
'hi, domm!'; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |