Data::Walk::More - Traverse Perl data structures, with more information during traversing
This document describes version 0.002 of Data::Walk::More (from Perl distribution Data-Walk-More), released on 2022-07-21.
use Data::Walk::More; # exports walk() and walkdepth() walk \&wanted, @items_to_walk; walkdepth \&wanted, @items_to_walk; # full options walk { wanted => \&wanted, # follow => 0, # whether to follow circular refs, default is 0. # bydepth => 0, # whether to descend into subnodes first. default is 0. # sortkeys => 1, # whether to visit hash values in key order. default is 1. # recurseobjects => 1, # whether to recurse into objects. default is 1. }, @items_to_walk;
This module is like Data::Walk, but there are a few differences, a few more options, and the callback gets more information.
The following variables are available for the callback. Unless specified otherwise, do not modify these during traversing.
Integer, starts at 0.
Can be set to true to prevent Data::Walk::More to descend into hash or array. Ineffective when you use "bydepth" option, since Data::Walk::More will have already descended into hash or array before the callback can prune it.
DWM also provides the full path (containers from the top level, in @containers and <@indexes>) instead of just the immediate container in $container and $index.
@containers
$container
$index
When traversing hash, $index package variable in DWM refers to hash key, not a number, which is more useful in my opinion.
You can prune (avoid descending) by setting $prune.
$prune
Options:
Please visit the project's homepage at https://metacpan.org/release/Data-Walk-More.
Source repository is at https://github.com/perlancar/perl-Data-Walk-More.
Data::Walk
perlancar <perlancar@cpan.org>
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.
This software is copyright (c) 2022, 2020 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Walk-More
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
To install Data::Walk::More, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Walk::More
CPAN shell
perl -MCPAN -e shell install Data::Walk::More
For more information on module installation, please visit the detailed CPAN module installation guide.