Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How do you check if a key exists without creating it ?

by Anonymous Monk
on Oct 06, 2012 at 08:44 UTC ( #997604=note: print w/ replies, xml ) Need Help??


in reply to How do you check if a key exists without creating it ?

Well, you start by not creating it :)

no autovivification;

if( exists $foo->{bar}{anything}{you}{want} ){ }

Or

use Data::Diver 'Dive';

if( my $want = Dive( $foo, qw/ bar anything you want / ) ){ ... }


Comment on Re: How do you check if a key exists without creating it ?
Select or Download Code
Re^2: How do you check if a key exists without creating it ?
by exilepanda (Monk) on Oct 06, 2012 at 09:00 UTC
    THANK YOU IT WORKS PERFECTLY!!! THANK YOU VERY MUCH!!! =D

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2015-07-04 20:11 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 (60 votes), past polls