Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: idiom for building hash of arrays?

by Anonymous Monk
on Jan 23, 2010 at 15:32 UTC ( [id://819193]=note: print w/replies, xml ) Need Help??


in reply to idiom for building hash of arrays?

push @{ $hash{$key} //= [] }, $current;

(For perl versions < 5.10, ||= is functionally the same in this case because the hash value is always a reference, which is false iff it is undefined.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-03-19 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found