Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 about the Monastery: (6)
As of 2019-02-18 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I use postfix dereferencing ...









    Results (98 votes). Check out past polls.

    Notices?