in reply to Size of an Hash reference

It depends on how you populate the hash. Compare:
use Data::Dumper; $hashR = {}; print Dumper $hashR; $hashR->{$x} = $y; print Dumper $hashR

Output:

$VAR1 = {}; $VAR1 = { '' => undef };
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Size of an Hash reference
by dvinay (Acolyte) on Nov 11, 2013 at 14:53 UTC

    Exactly i used the second way to populate my hash

    $hashR->{$x} = $y;

    reference, so is it because of this, that there is an empty key pointing to undef value

    anything wrong in populating the hash reference in above mentioned way...?

      Yes, but, apparently, neither $x nor $y was defined when you did it. The remedy is probably to check that $x and $y are defined before populating the hash with these values (especially $x).

        Thanks a lot for your help,

        i have one more doubt if i want to check the existence of an key in an hash reference

        here is this i have tried

        print Dumper \$returnvalue; $VAR1 = \{ ' WWN2' => ' 5678', ' WWN1' => ' 125689' }; my $string="WWN1"; if (exists $returnvalue->{$string})

        to my surprise its returning false

        Any clue why its happening, is my if condition correct or not