Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by exilepanda (Monk)
on Oct 06, 2012 at 08:36 UTC ( #997601=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Data::Dumper;
    $x = {};
    ...
    1 if ( exists $x->{Y}{X}  ) ;
    1 if ( defined $x->{Z}{A}  );
    print Dumper $x;
    
  2. or download this
    $VAR1 = {
              'Z' => {},
              'Y' => {}
            };
    
  3. or download this
    if ( $x->{Y} ) {
      if ( $x->{Y}{Z} ) {
        1 if ( $x->{Y}{Z}{A} ) ;
      }
    } ; # $VAR={};
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://997601]
Approved by philipbailey
Front-paged by philipbailey
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2015-07-04 06:27 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 (58 votes), past polls