|
|
| Just another Perl shrine | |
| PerlMonks |
Re: Making a failed hash lookup return something other than undefby thelenm (Vicar) |
| on Nov 13, 2003 at 20:04 UTC ( #306917=note: print w/ replies, xml ) | Need Help?? |
|
The code you posted has a problem when a hash entry exists but has a false value like 0 or undef. The straightforward way to test whether a hash entry exists is to use exists, e.g.:
This is not particularly pretty, but works, and I don't know of a more succinct way to do the same thing. -- Mike --
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||