in reply to Printing from a hash table
- As haukex already stated, exists is superfluous, as keys can give you existing keys only, to loop over
- for this purpose, undef and empty (and zero) are to be handled the same, you can simply test if/unless $birthdays{$name}. See Scalar values in perldata:
A scalar value is interpreted as FALSE in the Boolean sense if it is undefined, the null string or the number 0 (or its string equivalent, "0"), and TRUE if it is anything else. The Boolean context is just a special kind of scalar context where no conversion to a string or a number is ever performed.
|
---|
In Section
Seekers of Perl Wisdom