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 15, 2013 at 10:04 UTC ( #1018875=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

You don't even need the exists (assuming you don't have a weird freeform data structure):

if (Hash{$neededVal} and $Hash{$neededVal}{param1} and $Hash{$neededVal}{param1}{key1} > 4) {


Comment on Re^2: Checking if hash value exists without implicitly defining it
Select or Download Code
Replies are listed 'Best First'.
Re^3: Checking if hash value exists without implicitly defining it
by Kenosis (Priest) on Feb 15, 2013 at 15:47 UTC

    Yes, you're correct! Originally omitted exists when not testing for the final value--then overgeneralized. However, testing $Hash{$neededVal}{param1}{key1} would fail when $Hash{$neededVal}{param1}{key1} == 0, but expliciting testing the value, as you've shown, would remedy that.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2015-07-31 21:28 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 (282 votes), past polls