Greetings, monks, who are so wise in the ways of science.*
I have a HoHoH... that looks something like this:
$VAR1 = { '1' => { '1a' => {} }, '2' => { '2a' => { '2b' => {} } '2c' => {}, } };
I need to walk through this structure and identify one or more elements that meet certain criteria. Once I find the element(s), I need to report not just the element name(s) (e.g., 2a) but also the path(s) to that element (e.g., 2 -> 2a).
I vaguely recall reading about similar problems but I suspect they focused on only traversing the structure - my searches turned up empty. I could brute-force this, but it seems like a module might already exist to do it (perhaps something along the lines of Algorithm::Loops?).
Suggestions and/or snippets are greatly appreciated. Thanks in advance.
Update: Thanks for the responses. jdporter's example gave me a good starting point.
*With proper attribution (and apologies) to Monty Python and the Holy Grail, of course. :-)
In reply to Recursive traversal of a HoH... and paths by bobf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |