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;
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;
print scalar(keys %hash);
ReplyDelete