Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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
Re^3: Checking if hash value exists without implicitly defining it
by choroba (Abbot) on Feb 14, 2013 at 17:26 UTC
    Well, it only breaks for the false values like 0 or "" or undef.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
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.

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 meditating upon the Monastery: (12)
As of 2014-09-22 17:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls