Feed on

getting the size of a hash is slightly non-intuitive in perl:

print “my hash size is: ” . keys(%my_hash);

Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

One Response to “get size of hash in perl”

  1. on 04 Aug 2008 at 3:11 pm Marx0r

    Didn’t know _that_ would work. I would have used scalar(keys(%my_hash)) in that case.

Did I get this wrong? Let me know!

Trackback URI | Comments RSS