5% assure discount from here only

Tuesday, January 25, 2011

(10) How to know how many entries are in a hash?

Solution :

my $key_count = keys %hash; # must be scalar context!

If you want to find out how many entries have a defined value than:

my $defined_value_count = grep { defined } values %hash;

1 comment: