Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Answer: How do I find out if a hash is empty?

by particle (Vicar)
on Jun 11, 2002 at 22:49 UTC ( #173685=categorized answer: print w/replies, xml ) Need Help??

Q&A > hashes > How do I find out if a hash is empty? - Answer contributed by particle

a hash in scalar context returns (somewhat uselessly -- except for now,) the number of slots filled out of the number of slots allocated. so scalar %hash will equal 0 if no slots are allocated.

print 'empty' unles scalar %hash;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2019-10-22 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?