Thanks a lot for your code. I need to apologize for not using it, because I ended up with my own solution. What I do now is instead of storing the whole array, I just shift the value off and store it in a hash table. In other words I am using parallel arrays with identical subscripts, and this seems to work fine recursing over the whole structure.

But I'll add a bookmark to your solution because it does answer the question by storing the reference to the array. Thanks!

Just for laughs, here is my code. I am recursing through 6 levels this way, but I feel it will work for any number of levels:

$query[$level]->execute; while((@level_data)=$query[$level]->fetchrow_array) { %treepos = (); # reset the whereclause for a new branch %pathpos = (); $treepos{$key} = shift @level_data; $pathquery[$level] = &path_sql($childlevel,$treepos{$key}); while((@path_data)=$pathquery[$level]->fetchrow_array) { $pathpos{$key} = shift @path_data; &level_proc; } } sub level_proc { $query[$childlevel] = &level_sql($childlevel,$treepos{$key}); while((@level_data)=$query[$childlevel]->fetchrow_array) { &setlevel($childlevel); $treepos{$key} = shift @level_data; &path_proc; $treepos{$key} = undef; &setlevel($parlevel); } sub path_proc { $pathquery[$level]= &path_sql($pathpos{$parkey},$treepos{$key} +); while((@path_data)=$pathquery[$level]->fetchrow_array) { $pathpos{$key} = shift @path_data; &children_proc; } } } sub children_proc { &children_sql($pathpos{$key},$childlevel); &level_proc; }

In reply to Re^2: Two-dimensional dynamic array by Peamasii
in thread Two-dimensional dynamic array by Peamasii

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.