in reply to Re: Accessing an AoHoAoH
in thread Accessing an AoHoAoH

CountZero, not sure I understand. Ran Data::Dumper and got:
$VAR1 = { 'chapter' => 'Basic', 'page' => [ { 'paragraph' => 'lesson1' }, { 'paragraph' => 'lesson2' } ] }; $VAR2 = { 'chapter' => 'Advanced', 'page' => [ { 'paragraph' => 'lesson3' }, { 'paragraph' => 'lesson4' } ] };
What am I missing? Thanks

—Brad
"A little yeast leavens the whole dough."

Replies are listed 'Best First'.
Re^3: Accessing an AoHoAoH
by ambrus (Abbot) on Jun 05, 2004 at 20:45 UTC

    That's what you should get if you write something like dump @AoH; because @AoH "flattens" to a one-element list in the list context of the function call. (This was just a guess, but I'm sure in what I'll write below.)

    This way, however, you can not easily access the contents of the deep datastructure, as you can't index the array in such a way that it flattens automatically, so you have to use a 0 as a first array index, just as CountZero said.

    To change, either use a scalar variable, or (perhaps better) use an array variable, just assign it like @AoH= ({...}, {...}, ...);, not @AoH= [{...}, {...}, ...];.

      Gotcha ambrus. Helpful to know! Thanks

      —Brad
      "A little yeast leavens the whole dough."
Re^3: Accessing an AoHoAoH
by CountZero (Bishop) on Jun 06, 2004 at 07:03 UTC
    Try print Dump(\@AoH);

    Then you see the extra level of the @AoH array

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law