Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: hash deref confusion: Intermediate Perl

by BrowserUk (Patriarch)
on Jul 30, 2012 at 06:41 UTC ( #984363=note: print w/replies, xml ) Need Help??


in reply to hash deref confusion: Intermediate Perl

But, in the next line, "@$self" is syntax for dereferencing an array reference, not a hash reference!

The construct you refer to is called a 'hash slice' -- see perldata#slices.

It assignes the 4 values derived from spliting $STANDINGS{$name} (or the four 0s from the constant) to the the four keys:

qw[ wins places shows losses ]
.

That one line is (mostly) equivalent to:

$self->{wins} = $STANDINGS[ 0 ] || 0; $self->{places} = $STANDINGS[ 1 ] || 0; $self->{shows} = $STANDINGS[ 2 ] || 0; $self->{looses} = $STANDINGS[ 3 ] || 0;

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2023-02-04 21:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?