CXC-Data-Visitor
view release on metacpan or search on metacpan
examples/revisit_container_contents.pl view on Meta::CPAN
#! perl
use v5.20;
use strict;
use experimental 'signatures';
use Ref::Util 'is_hashref', 'is_arrayref';
use CXC::Data::Visitor 'visit', -results;
use builtin::compat 'load_module';
use lib::relative q{.};
load_module 'utils';
my %struct = (
fruit => {
berry => 'purple',
apples => [ 'fuji', 'macoun' ],
} );
my %context = (
rows => [],
struct_map => {},
);
visit(
\%struct,
sub ( $kydx, $vref, $context, $meta ) {
my $path = render_element( \%struct, $kydx, $vref, $context, $meta );
my $return = RESULT_CONTINUE;
$return |= RESULT_REVISIT_CONTAINER
if $path eq '{fruit}{apples}[0]' && $meta->{visit} == 1;
return $return;
},
context => \%context,
);
render_table( $context{rows} );
( run in 0.562 second using v1.01-cache-2.11-cpan-39bf76dae61 )