Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 surveying the Monastery: (8)
As of 2014-09-20 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (151 votes), past polls