![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: non-autovivifing hashby lofichurch (Beadle) |
on Jul 02, 2003 at 20:02 UTC ( #270928=note: print w/replies, xml ) | Need Help?? |
Why not use exists() first, before attempting to assign the value? Why change the underlying operation of the language, when all you have to change is your methodology? I find it a useful practice, that whenever I expect a certain key in a certain hash, to use exists() to verify that the key exists before attempting to read its value. exists() will NOT create a key if it does not already exist. e.g.: if( exists($hash{"$key"}) ) { print("You have \$hash{'$key'}\n"); } else { print("You've messed up with \$hash and $key.\n"); } I'd absolutely hate it if anyone ever turned off the automatic creation of keys in a hash on any of my scripts. !c
In Section
Seekers of Perl Wisdom
|
|