in reply to Dump filtered subtree?

antiquing

How to find all occurrences of a key in a deeply nested structure?, Re: Google decoder (how to access hash values, perl dereferencing string xpaths data dumper )

https://metacpan.org/pod/JSON::Path#SEE-ALSO

https://metacpan.org/pod/Data::CSel#SEE-ALSO

Replies are listed 'Best First'.
Re^2: Dump filtered subtree? ( Data::Path? )
by LanX (Saint) on Jan 28, 2020 at 12:37 UTC
    On a side note:

    I found many references and links for Data::Path but metacpan doesn't list it ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      This seems to be an indexing error in metacpan, or a specific choice made by metacpan, or a problem with the distribution.

      I thought it had maybe been deleted from CPAN, so using Google I searched for backpan data-path to find it on the Backpan. Google then showed me the link on the MetaCPAN site where it still lives.

      Maybe the cause is the META.yml file, or something else, as rt://55483 noted that problem 10 years ago already...

Re^2: Dump filtered subtree?
by LanX (Saint) on Jan 28, 2020 at 11:34 UTC
    These are all good tools, some even extract the path.

    But I couldn't find an example of reducing a complex data structure to essential parts.

    Data::Printer is good in visualizing, I'm surprised that this is so hard.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      These are all good tools, some even extract the path. But I couldn't find an example of reducing a complex data structure to essential parts.

      find_rehohy( $VAR1 ); sub find_rehohy { my( $root ) = @_; my $my_cb = sub { my $val = pp( $_[0] ); my $path = $_[1]; my $depth = $_[2]; my @Paths = @{ $_[3]||[] }; my $depthpad = ( " " x $depth ); my $varname = shift @Paths; # print "DiveVal( $varname, qw/ @{[ @Paths ]} /)\n$depthpad = $val +; #d$depth\n\n"; use Data::Diver qw/ DiveVal /; use Data::Printer; if( $Paths[-1] eq 'field' ){ p( @Paths ); my $reff = 'HASH' eq ref $root ? {} : []; DiveVal( $reff , @Paths ) = $_[0]; p $reff ; return; } return; }; rehohy( $root, 0=> '$ref->' , $my_cb ); } __END__ [ [0] "content", [1] "errors", [2] 0, [3] "field" ] \ { content { errors [ [0] { field "merge_fields" } ] } }