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

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

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

    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.