Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 musing on the Monastery: (6)
As of 2015-08-01 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls