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

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

Replies are listed 'Best First'.
Re^5: Size of an Hash reference
by choroba (Cardinal) on Nov 11, 2013 at 16:27 UTC
    The keys in the hash start with a space, $string does not.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^5: Size of an Hash reference
by Laurent_R (Canon) on Nov 11, 2013 at 16:52 UTC

    It's because your keys have a leading space.

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