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?? |
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.)
In Section
Seekers of Perl Wisdom
|
|