http://www.perlmonks.org?node_id=684059
tford has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to define a default value for a hash? For example, if you access the hash with any of the known keys, the expected data gets retrieved, but can you define a special default value so that if you try and access the hash with an unrecognized key, it always returns that special value? Here is an example of what I would like to do.
my %description = ( a => 'a vowel', b => 'a consonant', '' => 'not in the alphabet' #description of anything else ); print("a is $description{'a'}\n"); print("b is $description{'b'}\n"); print("~ is $description{'~'}"); #Would like the following: #"~ is not in the alphabet"
This doesn't work, but hopefully it's clear what I would like to happen.

Any help will be greatly appreciated!