in reply to Re: Re: Multi dimensional arrays
in thread Multi dimensional arrays

Just because it can be written that way doesn't mean that we should teach it that way. It is much better for someone to learn how it works before they learn the shortcuts.

Replies are listed 'Best First'.
Re4: Multi dimensional arrays
by Hofmator (Curate) on Feb 10, 2003 at 14:54 UTC
    I agree with you, but I don't consider $array[2]->[0] as a shortcut. It's a imho more readable alternative writing of your ${$array[2]}[0]. Perl has enough line noise as it is, so I don't see any point in promoting this :)

    Of course, it is a good thing to explain what $array[2]->[0] does, e.g. by pointing to tye's tutorial, exactly as you have done.

    The last shortcut to arrive at $array[2][0] is not necessary but why not mention it while we are at the topic. This abbreviation was introduced so that it looks like we are straightforwardly accessing a 2D array - which on purpose hides the 'gory details'. Once you have understood the underlying concepts, you don't have to deal with them explicitly any more ... that's Perl.

    -- Hofmator