Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2016-09-25 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (473 votes). Check out past polls.