Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: hash deref confusion: Intermediate Perl

by davido (Cardinal)
on Jul 30, 2012 at 06:38 UTC ( [id://984361]=note: print w/replies, xml ) Need Help??


in reply to hash deref confusion: Intermediate Perl

Sometimes for me I find it more readable to place the inner reference in brackets, which sort of serves to remind me that it's a reference.

@{$self}{ qw( wins places shows losses ) } = ....

We already know $self is a hashref. What happens when you put an @ in front of a hash, and a pair of curly brackets after it? Let's look at the similar syntax, but first remove the reference indirection (and complexity):

@somehash{ qw( wins places shows losses ) } = ....

That should ring a bell (you're looking at a hash slice).


Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 13:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found