in reply to Generation of a Hash of Hashes

What am I missing here?

Maybe I'm the one missing something here, but why is "Sub Item 2" in $result{1}{12} and not in $result{1}{12}{0}? Because that's what it seems you want to do by looking at "ITEM", "Sub Item 1"... OTOH, "Item X" and "And Another Item" aren't placed after a 0 either...

Could you ellaborate a little more (in words) on what you're trying to do?

Update: And why do you use IO::All; if you're not doing anything that requires it? :-\

Replies are listed 'Best First'.
Re^2: Generation of a Hash of Hashes
by jhourcle (Prior) on Mar 25, 2005 at 23:56 UTC
    $result{1}{12}{0}? Because that's what it seems you want to do by looking at "ITEM", "Sub Item 1"... OTOH, "Item X" and "And Another Item" aren't placed after a 0 either...

    Trees are a PITA, plain and simple. What you're not seeing in the example is that there's some extra logic being assumed, that makes sense to someone who's dealing with the a variable depth structure, but actually makes it more difficult to parse overall. (when it's a leaf, and not a branch, it's using different syntax -- which is annoying, when you have to add a branch there, and move the leaf)

    Of course, I don't know if there's something already in place to deal with the structure. If I were starting from scratch, I'd probably use something like:

    Of course, this assumes that 0 is never used as an index, and with this structure is that the individual items need to know their path up the tree to get their whole code. If the indexes are always numbers, the following may be useful:

    (and I'm surprised that tilly and I both use the same method for walking trees ... anyone else have another way to do it?)

Re^2: Generation of a Hash of Hashes
by Miguel (Friar) on Mar 25, 2005 at 22:34 UTC
    "And why do you use IO::All; if ..." Oopss... my mistake :-) That's not used here, of course.