Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Answer: How can I find the number of elements in a hash?

by OeufMayo (Curate)
on Mar 09, 2001 at 02:22 UTC ( #63115=categorized answer: print w/replies, xml ) Need Help??

Q&A > hashes > How can I find the number of elements in a hash? - Answer contributed by OeufMayo

The easiest way is to have the keys function evaluated in scalar context:

%hash = ('foo'=>1, 'bar'=>3); $count = keys %hash;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and dust plays in a shaft of sunlight...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2016-12-10 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (164 votes). Check out past polls.