| 1 | package Data::DPath; | ||
| 2 | # git description: v0.59-6-g53d9a3f | ||
| 3 | |||
| 4 | 11 | our $AUTHORITY = 'cpan:SCHWIGON'; | |
| 5 | # ABSTRACT: DPath is not XPath! | ||
| 6 | 11 | $Data::DPath::VERSION = '0.60'; | |
| 7 | 11 | ▶ | use 5.008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 11 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 11 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 11 | our $DEBUG = 0; | |
| 12 | 11 | our $USE_SAFE = 1; | |
| 13 | 11 | our $PARALLELIZE = 0; | |
| 14 | |||
| 15 | 11 | ▶ | use Data::DPath::Path; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 11 | ▶ | use Data::DPath::Context; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | 8 | ▶ | sub build_dpath { |
|
Subroutine
build_dpath: called CC=1 SCAR=0.0
Pod
documented
| |||
| 19 | 375 | ▶ | return sub ($) { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 20 | 375 | my ($path_str) = @_; | |
| 21 | 375 | Data::DPath::Path->new(path => $path_str); | |
| 22 | 8 | }; | |
| 23 | } | ||
| 24 | |||
| 25 | 4 | ▶ | sub build_dpathr { |
|
Subroutine
build_dpathr: called CC=1 SCAR=0.0
Pod
documented
| |||
| 26 | 37 | ▶ | return sub ($) { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 27 | 37 | my ($path_str) = @_; | |
| 28 | 37 | Data::DPath::Path->new(path => $path_str, give_references => 1); | |
| 29 | 4 | }; | |
| 30 | } | ||
| 31 | |||
| 32 | 1 | ▶ | sub build_dpathi { |
|
Subroutine
build_dpathi: called CC=1 SCAR=0.0
Pod
documented
| |||
| 33 | 1 | ▶ | return sub ($) { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 34 | 1 | my ($data, $path_str) = @_; | |
| 35 | |||
| 36 | 1 | 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 | }; | |
| 43 | } | ||
| 44 | |||
| 45 | 11 | ▶ | use Sub::Exporter -setup => { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 46 | exports => [ dpath => \&build_dpath, | ||
| 47 | dpathr => \&build_dpathr, | ||
| 48 | dpathi => \&build_dpathi, | ||
| 49 | ], | ||
| 50 | groups => { all => [ 'dpath', 'dpathr' ] }, | ||
| 51 | 11 | }; | |
| 52 | |||
| 53 | 6 | ▶ | sub match { |
|
Subroutine
match: called CC=1 SCAR=0.0
Pod
documented
| |||
| 54 | 6 | my ($class, $data, $path_str) = @_; | |
| 55 | 6 | Data::DPath::Path->new(path => $path_str)->match($data); | |
| 56 | } | ||
| 57 | |||
| 58 | 2 | ▶ | sub matchr { |
|
Subroutine
matchr: called CC=1 SCAR=0.0
Pod
documented
| |||
| 59 | 2 | my ($class, $data, $path_str) = @_; | |
| 60 | 2 | Data::DPath::Path->new(path => $path_str)->matchr($data); | |
| 61 | } | ||
| 62 | |||
| 63 | # ------------------------------------------------------------ | ||
| 64 | |||
| 65 | 11 | 1; | |
| 66 | |||
| 67 | __END__ | ||