line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::DPath; |
2
|
|
|
|
|
|
|
# git description: v0.56-7-g681b3f6 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:SCHWIGON'; |
5
|
|
|
|
|
|
|
# ABSTRACT: DPath is not XPath! |
6
|
|
|
|
|
|
|
$Data::DPath::VERSION = '0.57'; |
7
|
10
|
|
|
10
|
|
780965
|
use 5.008; |
|
10
|
|
|
|
|
47
|
|
8
|
10
|
|
|
10
|
|
73
|
use strict; |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
285
|
|
9
|
10
|
|
|
10
|
|
67
|
use warnings; |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
796
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $DEBUG = 0; |
12
|
|
|
|
|
|
|
our $USE_SAFE = 1; |
13
|
|
|
|
|
|
|
our $PARALLELIZE = 0; |
14
|
|
|
|
|
|
|
|
15
|
10
|
|
|
10
|
|
3923
|
use Data::DPath::Path; |
|
10
|
|
|
|
|
39
|
|
|
10
|
|
|
|
|
370
|
|
16
|
10
|
|
|
10
|
|
73
|
use Data::DPath::Context; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
2600
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub build_dpath { |
19
|
|
|
|
|
|
|
return sub ($) { |
20
|
387
|
|
|
387
|
|
1534886
|
my ($path_str) = @_; |
21
|
387
|
|
|
|
|
3191
|
Data::DPath::Path->new(path => $path_str); |
22
|
8
|
|
|
8
|
1
|
1397
|
}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub build_dpathr { |
26
|
|
|
|
|
|
|
return sub ($) { |
27
|
38
|
|
|
38
|
|
115960
|
my ($path_str) = @_; |
28
|
38
|
|
|
|
|
254
|
Data::DPath::Path->new(path => $path_str, give_references => 1); |
29
|
4
|
|
|
4
|
1
|
355
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub build_dpathi { |
33
|
|
|
|
|
|
|
return sub ($) { |
34
|
1
|
|
|
1
|
|
1675
|
my ($data, $path_str) = @_; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
40
|
Data::DPath::Context |
37
|
|
|
|
|
|
|
->new |
38
|
|
|
|
|
|
|
->current_points([ Data::DPath::Point->new->ref(\$data) ]) |
39
|
|
|
|
|
|
|
->_search(Data::DPath::Path->new(path => "/")) |
40
|
|
|
|
|
|
|
->_iter |
41
|
|
|
|
|
|
|
->value; # there is always exactly one root "/" |
42
|
1
|
|
|
1
|
1
|
114
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
10
|
|
|
|
|
154
|
use Sub::Exporter -setup => { |
46
|
|
|
|
|
|
|
exports => [ dpath => \&build_dpath, |
47
|
|
|
|
|
|
|
dpathr => \&build_dpathr, |
48
|
|
|
|
|
|
|
dpathi => \&build_dpathi, |
49
|
|
|
|
|
|
|
], |
50
|
|
|
|
|
|
|
groups => { all => [ 'dpath', 'dpathr' ] }, |
51
|
10
|
|
|
10
|
|
5128
|
}; |
|
10
|
|
|
|
|
101425
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub match { |
54
|
6
|
|
|
6
|
1
|
34526
|
my ($class, $data, $path_str) = @_; |
55
|
6
|
|
|
|
|
57
|
Data::DPath::Path->new(path => $path_str)->match($data); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub matchr { |
59
|
2
|
|
|
2
|
1
|
44
|
my ($class, $data, $path_str) = @_; |
60
|
2
|
|
|
|
|
27
|
Data::DPath::Path->new(path => $path_str)->matchr($data); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |