Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

( #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 romping around the Monastery: (4)
As of 2016-08-24 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (336 votes). Check out past polls.