in reply to Re: Size of an Hash reference
in thread Size of an Hash reference

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...?

Replies are listed 'Best First'.
Re^3: Size of an Hash reference
by Laurent_R (Canon) on Nov 11, 2013 at 15:48 UTC

    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
        The keys in the hash start with a space, $string does not.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        It's because your keys have a leading space.

        Edit: Oops, I had not seen that choroba had already answered. Sorry for the repetition.