Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Checking if hash value exists without implicitly defining it

by Anonymous Monk
on Feb 14, 2013 at 16:40 UTC ( #1018754=note: print w/replies, xml ) Need Help??


in reply to Re: Checking if hash value exists without implicitly defining it
in thread Checking if hash value exists without implicitly defining it

Huh. I thought you needed to use exists to avoid AVing the hash key you're reading, but that code works.

This should simplify some of my code.

  • Comment on Re^2: Checking if hash value exists without implicitly defining it

Replies are listed 'Best First'.
Re^3: Checking if hash value exists without implicitly defining it
by Kenosis (Priest) on Feb 14, 2013 at 17:42 UTC

    My apologies, as it should be written as:

    ... if ( exists $Hash{$neededVal} and exists $Hash{$neededVal}{param1} and exists $Hash{$neededVal}{param1}{key1} ) { ...

    Will correct the original...

    Update: Replaced defined with exists. Thank you, choroba.

      What is wrong with plain old exists?
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        Preferrable. Will update. Thank you.

Re^3: Checking if hash value exists without implicitly defining it
by choroba (Chancellor) on Feb 14, 2013 at 17:26 UTC
    Well, it only breaks for the false values like 0 or "" or undef.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2016-10-01 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (7 votes). Check out past polls.