in reply to Re: Help explaining data structure
in thread Help explaining data structure

Yes, I see now. Probably should have stared at it a while longer before posting. I wonder if there is a friendlier way to write it? I don't think the arrow notation can be applied.

Replies are listed 'Best First'.
Re^3: Help explaining data structure
by sauoq (Abbot) on Oct 03, 2005 at 03:16 UTC
    I don't think the arrow notation can be applied.

    Sure it can... These are all equivalent:

    1. $val{$file}[3][$num{$alias}{save}] 2. $val{$file}[3][$num{$alias}->{save}] 3. $val{$file}[3]->[$num{$alias}{save}] 4. $val{$file}[3]->[$num{$alias}->{save}] 5. $val{$file}->[3][$num{$alias}{save}] 6. $val{$file}->[3][$num{$alias}->{save}] 7. $val{$file}->[3]->[$num{$alias}{save}] 8. $val{$file}->[3]->[$num{$alias}->{save}]
    Of those, I would prefer number 6 with some whitespace added for readability.
    $val{$file}->[3][ $num{$alias}->{save} ]
    -sauoq
    "My two cents aren't worth a dime.";
    
Re^3: Help explaining data structure
by pg (Canon) on Oct 03, 2005 at 03:19 UTC
    "Yes, I see now."

    You did see from the beginning ;-) array of array refs is the same as two dimentional array. Put in this way, two dimentional array is the logical view across languages, and array of array refs is the Perl way of realize the concept.

    Due to the fact that the second level arrays are not required to have the same length in Perl, they have to be refs, so that the information about their lengthes is not lost because of the flattening.