NAME
Data::ZPath::NodeList - list wrapper for Data::ZPath nodes
SYNOPSIS
my $path = Data::ZPath->new('/foo/bar');
my $list = $path->evaluate($root);
my @nodes = $list->all;
my $first = $list->first;
my $last = $list->last;
DESCRIPTION
Objects of this class contain a list of Data::ZPath::Node objects.
METHODS
all
Returns all nodes as a list.
values
Returns all node values as a list.
Equivalent to map { $_->value } $nodelist->all.
first
Returns the first node, or undef.
last
Returns the last node, or undef.
find( $zpath )
Calls find on all nodes in the list and returns the list of results.
grep( \&callback )
Filters nodes using a callback and returns matching nodes.
The callback receives no positional arguments, but $_ is locally set to each node's value while it runs.
In list context, this returns matching nodes as a plain list. In scalar context, this returns a new Data::ZPath::NodeList object.
my @nodes = $list->grep( sub {
defined and /foo/
} );
map( \&callback )
Maps each node through a callback and returns replacement nodes.
The callback receives no positional arguments, but $_ is locally set to each node's value while it runs.
Each callback result is normalized as follows:
Data::ZPath::NodeListobjects are flattened into nodes.Data::ZPath::Nodeobjects are kept as-is.Any other value becomes a node via
Data::ZPath::Node->from_root.
In list context, this returns mapped nodes as a plain list. In scalar context, this returns a new Data::ZPath::NodeList object.
my $mapped = $list->map( sub {
uc
} );
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2026 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.