| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Data::DPath; | 
| 2 |  |  |  |  |  |  | # git description: v0.58-3-g9898e48 | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | our $AUTHORITY = 'cpan:SCHWIGON'; | 
| 5 |  |  |  |  |  |  | # ABSTRACT: DPath is not XPath! | 
| 6 |  |  |  |  |  |  | $Data::DPath::VERSION = '0.59'; | 
| 7 | 10 |  |  | 10 |  | 749232 | use 5.008; | 
|  | 10 |  |  |  |  | 128 |  | 
| 8 | 10 |  |  | 10 |  | 58 | use strict; | 
|  | 10 |  |  |  |  | 17 |  | 
|  | 10 |  |  |  |  | 201 |  | 
| 9 | 10 |  |  | 10 |  | 45 | use warnings; | 
|  | 10 |  |  |  |  | 16 |  | 
|  | 10 |  |  |  |  | 658 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | our $DEBUG = 0; | 
| 12 |  |  |  |  |  |  | our $USE_SAFE = 1; | 
| 13 |  |  |  |  |  |  | our $PARALLELIZE = 0; | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 10 |  |  | 10 |  | 4706 | use Data::DPath::Path; | 
|  | 10 |  |  |  |  | 38 |  | 
|  | 10 |  |  |  |  | 461 |  | 
| 16 | 10 |  |  | 10 |  | 66 | use Data::DPath::Context; | 
|  | 10 |  |  |  |  | 20 |  | 
|  | 10 |  |  |  |  | 2529 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub build_dpath { | 
| 19 |  |  |  |  |  |  | return sub ($) { | 
| 20 | 390 |  |  | 390 |  | 1310448 | my ($path_str) = @_; | 
| 21 | 390 |  |  |  |  | 1821 | Data::DPath::Path->new(path => $path_str); | 
| 22 | 8 |  |  | 8 | 1 | 1078 | }; | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | sub build_dpathr { | 
| 26 |  |  |  |  |  |  | return sub ($) { | 
| 27 | 38 |  |  | 38 |  | 92615 | my ($path_str) = @_; | 
| 28 | 38 |  |  |  |  | 185 | Data::DPath::Path->new(path => $path_str, give_references => 1); | 
| 29 | 4 |  |  | 4 | 1 | 236 | }; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | sub build_dpathi { | 
| 33 |  |  |  |  |  |  | return sub ($) { | 
| 34 | 1 |  |  | 1 |  | 1583 | my ($data, $path_str) = @_; | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 1 |  |  |  |  | 28 | 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 | 138 | }; | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 10 |  |  |  |  | 105 | 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 |  | 7065 | }; | 
|  | 10 |  |  |  |  | 121493 |  | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub match { | 
| 54 | 6 |  |  | 6 | 1 | 25758 | my ($class, $data, $path_str) = @_; | 
| 55 | 6 |  |  |  |  | 29 | Data::DPath::Path->new(path => $path_str)->match($data); | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | sub matchr { | 
| 59 | 2 |  |  | 2 | 1 | 48 | my ($class, $data, $path_str) = @_; | 
| 60 | 2 |  |  |  |  | 8 | Data::DPath::Path->new(path => $path_str)->matchr($data); | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | # ------------------------------------------------------------ | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | 1; | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | __END__ |