in reply to How to check if hash has empty hash reference? [RESOLVED]

Does this help?

#!/usr/bin/env perl use strict; use warnings; my %hash = ( key1 => 'value', key2 => undef, key3 => {}, key4 => { foo => 99 }, ); foreach my $key (qw(key1 key2 key3 key4)) { my $reftype = ref ($hash{$key}); if ($reftype && $reftype eq 'HASH') { my $entries = scalar keys %{$hash{$key}}; print "\$hash{$key} is a hashref which is " . ($entries ? 'not ' : '') . "empty.\n"; } else { print "\$hash{$key} is not a hashref\n"; } }

Count the items to see if a hashref is empty or not.

Replies are listed 'Best First'.
Re^2: How to check if hash has empty hash reference?
by thanos1983 (Parson) on Feb 15, 2017 at 16:53 UTC

    Hello hippo

    Thanks your solution pointed me to right direction, to finally resolved my issue on my code.

    Thanks again for your time and effort assisting me.

    Seeking for Perl wisdom...on the process of learning...not there...yet!