Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jun 232010

Counting the number of pair(s) in Perl's hash


If you have a Perl's hash variable, e.g. %hash, you can count the total number of hash pair (i.e. key/value) in that variable, like the following.

my $count = scalar keys %hash; 

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>