Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by wind (Priest)
on Oct 06, 2012 at 08:43 UTC ( #997603=note: print w/replies, xml ) Need Help??


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

You're just falling into autovivification. Check for existence of the lower level first if you don't want it autocreated:

use Data::Dumper; $x = {}; 1 if ( $x->{Y} && exists $x->{Y}{X} ) ; 1 if ( $x->{Z} && defined $x->{Z}{A} ); print Dumper $x;

Replies are listed 'Best First'.
Re^2: How do you check if a key exists without creating it ?
by exilepanda (Pilgrim) on Oct 06, 2012 at 11:34 UTC
    haha.. yes, lesson just learned! Thank you very much! =)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997603]
help
Chatterbox?
Discipulus psylocibina party?
[Discipulus]: listen monks: do you think is possible to realize here at pm some kind of collaborative works? beyond ask & answer, i mean
[Tanktalus]: isn't that what github, sourceforge, gitlabs, etc., are for?
[Discipulus]: mmh.. i was no strictly thinking to programs; more on some new tutorials

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-09-22 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (269 votes). Check out past polls.

    Notices?