in reply to What is $x{$y}?

Thanks guys.

Just one more question. What about $x{@y}?

Replies are listed 'Best First'.
Re^2: What is $x{$y}?
by AnomalousMonk (Archbishop) on Sep 11, 2012 at 00:22 UTC

    In the  $x{ @y } expression, array  @y is being evaluated in scalar context, i.e., it yields the number of elements of the array. This number is then stringized as a key for the hash.

    >perl -wMstrict -le "my %hash = qw(one uno two dos); my @y = 5 .. 8; ;; print 'scalar @y: ', scalar @y; print 'does not exist' if not exists $hash{ @y }; ;; $hash{ '4' } = 'four'; print 'does exist: ', qq{'$hash{ @y }'} if exists $hash{ @y }; " scalar @y: 4 does not exist does exist: 'four'
Re^2: What is $x{$y}?
by Anonymous Monk on Sep 11, 2012 at 00:03 UTC

    Just one more question. What about $x{@y}?

    You tell us? Try It To See? Tutorials: Basic debugging checklist?

    I don't know what this means, do you have any idea?

    $ perl -MData::Dump -e " @x = 1..2; $y{@x} = @x; dd \%y " { 2 => 2 } $ perl -MData::Dump -e " @x = 1..4; $y{@x} = @x; dd \%y " { 4 => 4 }