http://qs321.pair.com?node_id=270928


in reply to non-autovivifing hash

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