Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Size of a hash 2

Status
Not open for further replies.

jerehart

Programmer
Joined
Jun 10, 1999
Messages
61
Location
US
How do I figure out the size of a hash? I am looking for something similar to $#ARRAY for an array size. Is there another way other than traversing through the whole hash?
 
There's no "size" function that I am aware of, but this should work:

Code:
$i=0;
while (($key,$value) = each %YOURHASH) { $i++; }

Hope that helps,
Segfault
 
Good one Brendan! Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Awesome one, Brendan. Helped more than one person!

-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
SCHWEEEET! that is what I was looking for Brendan, thanks!

Miah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top