Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-07-28 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (431 votes). Check out past polls.