Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Size of an Hash reference

by dvinay (Acolyte)
on Nov 11, 2013 at 16:21 UTC ( [id://1062015]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1062015]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-18 13:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found