Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 (Canon) 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: (5)
As of 2015-08-05 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (81 votes), past polls