The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Walk::More - Traverse Perl data structures, with more information during traversing

VERSION

This document describes version 0.002 of Data::Walk::More (from Perl distribution Data-Walk-More), released on 2022-07-21.

SYNOPSIS

 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;

DESCRIPTION

This module is like Data::Walk, but there are a few differences, a few more options, and the callback gets more information.

VARIABLES

The following variables are available for the callback. Unless specified otherwise, do not modify these during traversing.

$Data::Walk::More::depth

Integer, starts at 0.

@Data::Walk::More::containers

$Data::Walk::More::container

@Data::Walk::More::indexes

$Data::Walk::More::index

$Data::Walk::More::prune

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.

DIFFERENCES BETWEEN DATA::WALK::MORE (DWM) WITH DATA::WALK (DW)

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.

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.

FUNCTIONS

walk

Options:

wanted

bydepth

follow

sortkeys

recurseobjects

walkdepth

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Data-Walk-More.

SOURCE

Source repository is at https://github.com/perlancar/perl-Data-Walk-More.

SEE ALSO

Data::Walk

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

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.

COPYRIGHT AND LICENSE

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.

BUGS

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.