in reply to UPDATED: Recursive function adds data to a hash/array

If you want to attach an array to a hash element, try
$groups[$gcount]{sub}=[@subgroup]; my $first_data = $groups[0]{sub}[0];
The  [] creates an anonmyous array that is attached as a reference to  $groups[$gcount]{sub}.

Update: My gues is that the code is parsing nested tags. The sub recursively calls itself on the string $newvalue found between a pair of tags. When there is no more text to parse, the recursion ends. While parsing, the intent is to build a tree of data enclosed in the tags. Thus the question on nested data structures.

-Mark

Replies are listed 'Best First'.
Re: Re: Recursive function adds data to a hash/array
by darkphorm (Beadle) on Mar 10, 2004 at 20:10 UTC
    You've hit it on the head. The code parses tags, some of which can be nested, in order to insert data elements into the tags.

    When there are no more nested elements, there is no more recursion.

    This part works now... but I'm now trying to figure out how to recursively pull back out
    $groups[$indx]{sub}[$subindex]...