you could adapt

#!/usr/bin/perl -- use strict; use warnings; my %hoh = ( a => { b => { c => 4 }, }, d => { e => { f => 5, g => 6 }, }, h => { i => { i => { 2..5 }, j => { 0..3 }, k => { 7..10 }, }, j => { 0..3 }, k => { 7..10 }, }, ); rehoh( \%hoh ); sub rehoh { my( $hoh, $depth, $path, $callback ) = @_; $depth ||= 0; $path ||= ''; while( my( $key, $val ) = each %$hoh ){ if( ref $val ){ rehoh( $val , $depth + 1, "$path/$key" ); } else { if( $callback ){ $callback->($val, "$path/$key" ); } else { print "($depth)", " " x $depth, "$val\n"; print " " x ( length( "($depth)" ) + $depth ), "\@ $path/$key\ +n"; } } } } __END__ (2) 8 @ /h/k/7 (2) 10 @ /h/k/9 (2) 1 @ /h/j/0 (2) 3 @ /h/j/2 (3) 8 @ /h/i/k/7 (3) 10 @ /h/i/k/9 (3) 1 @ /h/i/j/0 (3) 3 @ /h/i/j/2 (3) 5 @ /h/i/i/4 (3) 3 @ /h/i/i/2 (2) 4 @ /a/b/c (2) 6 @ /d/e/g (2) 5 @ /d/e/f

or maybe JSON::Path#paths

read Tutorials Data Types and Variables,the basic datatypes, three, keys, values, ref

It seems a mistake to return a multidimensional structure when all you want is a bunch of xpath's, anyway :)


In reply to Re: Unwinding multidimensional HASH (path, xpath, json) by Anonymous Monk
in thread Unwinding multidimensional HASH by prassrin

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.