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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number of keys in a hash

Status
Not open for further replies.

EfratS

MIS
Aug 4, 2004
15
CA
Hi,
how can I know the number of keys I have in a hash?

Thanks.
 
Code:
%hash = (1 =>1, 2 => 2, 3 => 3);

@keys = keys(%hash);
$numkeys = @keys;

print $numkeys;

There will be better ways I'm sure, but you will end up with an array of the keys too in @keys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top