Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: hash deref confusion: Intermediate Perl

by davido (Cardinal)
on Jul 30, 2012 at 06:38 UTC ( #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? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2023-02-06 00:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (33 votes). Check out past polls.

    Notices?