Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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?
[1nickt]: Ah, I see. I did read some gamer mag reviews, and yes, they lamented the fact that laptops with no discrete video card are sold as "gaming" hardware.
[1nickt]: But, they do have red keyboard backlighting! And gargoyles on the front, or words like "Maxxx" here and there. They know their demographic!
[1nickt]: True gamers don;t buy Dells, HPs, or Lenovos, I think ;-)
[ambrus]: The keyboard I bought doesn't have backlighting. I specifically had to select for that, because so many keyboards these days have lights. Why would I want lights in the keyboard? I want lights in the room, such as on the ceiling, not in the keyboard.
choroba has a small USB lamp
[ww]: ++ all (phony labels re "gaming"

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2017-03-27 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.