Dear monastery

In continuation of Proper Way to Reference a Hash Value

Let's say you have a deeply nested data structure, but you want only to display the subtrees where an item (hash key or hash value or array) in between passes a test (eq or regex or whatever)

Data::Printer has filters but they are normally used to format the current item.

I have an idea how to implement it nevertheless, but am quite busy right now. And next week I will certainly forget it.

Extra challenge: print the correct Perl path to access this element.

Anyone interested?

Alternative approaches?

Update

I was asked what "subtree" means. Those nested items which are not predecessor or successor are not displayed.

Update

This would be the subtree for finding the "field" key in the linked thread.

\ { content { errors [ [0] { field "merge_fields", } ], }, }

the path would be ->{content}{errors}[0]{field}

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


In reply to Dump filtered subtree? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.