|XP is just a number
Default Hash Keyby tford (Beadle)
|on May 02, 2008 at 00:26 UTC
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.
This doesn't work, but hopefully it's clear what I would like to happen.
Any help will be greatly appreciated!