Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: What is $x{$y}?

by AnomalousMonk (Canon)
on Sep 11, 2012 at 00:22 UTC ( #992880=note: print w/replies, xml ) Need Help??

in reply to Re: What is $x{$y}?
in thread What is $x{$y}?

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'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992880]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-06-23 23:11 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (555 votes). Check out past polls.