XP is just a number | |
PerlMonks |
Re: Making a hash of arrays using referencesby NetWallah (Canon) |
on Apr 09, 2017 at 06:23 UTC ( [id://1187508]=note: print w/replies, xml ) | Need Help?? |
You will find this a frequent code pattern, young padewan. Here is a self-contained solution that demonstrates the idioms. This code uses "Autovivification" to avoid the issue you experienced - i.e. the same code handles both the case where the key is absent, and when present. Read all about it in perlref. OUTPUT:
...it is unhealthy to remain near things that are in the process of blowing up. man page for WARP, by Larry Wall
In Section
Seekers of Perl Wisdom
|
|