in reply to checking to see if a hash has data
If you want a count of the keys, use the keys() operator in scalar context.
my $key_total = keys %hash;
If you need something else, such as the count of the defined values, you have to do a bit more work.
my $defined_count = grep { defined } values %hash;
|
|---|