⭐ in reply to How do I find out if a hash is empty?
This has the drawback of actually going through fetching all the keys for a tied hash, but the alternative (if (!%hash) { print "Empty" }) doesn't work at all for tied hashes.
If tied hashes aren't a concern, either way will do, but there is a difference to be aware of: the keys version will reset the hash's iterator (see each) while the other way will leave it unchanged.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I find out if a hash is empty?
by Roy Johnson (Monsignor) on Nov 04, 2003 at 14:11 UTC |