in reply to Re: Dereferencing a Hash of Arrays
in thread Dereferencing a Hash of Arrays

Hmm ... so why does this work?

my @idontgetit = values %alphabet; say for @idontgetit->[0]->[0];

(It doesn't "work" in the sense of printing out what's desired but it does print out part of what's desired.)

Replies are listed 'Best First'.
Re^3: Dereferencing a Hash of Arrays
by Eliya (Vicar) on Jun 14, 2011 at 07:32 UTC

    @idontgetit holds the two array refs. @idontgetit->[0] indexes the first one of it, and the second ->[0] indexes the first element of the (inner) array.

    BTW, @idontgetit->[0]->[0] should better be written as $idontgetit[0]->[0]   (turn on warnings, and Perl will tell you why).

      I saw that warning before (I try to crack these nuts for a few hours before I ask the monks). I failed with $idontgetit->[0]->[0] and just went back to the @ syntax since it printed anything. Sometimes Perl forgives my syntax, sometimes not.