Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: What is $x{$y}?

by invaderzard (Acolyte)
on Sep 10, 2012 at 23:58 UTC ( [id://992877]=note: print w/replies, xml ) Need Help??


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 }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://992877]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found