<?xml version="1.0" encoding="windows-1252"?>
<node id="997601" title="How do you check if a key exists without creating it ?" created="2012-10-06 04:36:30" updated="2012-10-06 04:36:30">
<type id="115">
perlquestion</type>
<author id="930100">
exilepanda</author>
<data>
<field name="doctext">
Hi Monks, 

&lt;code&gt;
use Data::Dumper;
$x = {};
1 if ( exists $x-&gt;{W} ) ;
1 if ( defined $x-&gt;{X} ) ;
1 if ( $x-&gt;{Y} ) ;
1 if ( exists $x-&gt;{Y}{X}  ) ;
1 if ( defined $x-&gt;{Z}{A}  );
print Dumper $x;
&lt;/code&gt;

Result :&lt;code&gt;
$VAR1 = {
          'Z' =&gt; {},
          'Y' =&gt; {}
        };
&lt;/code&gt;

What I don't want is Z, Y create by itself, when I try to check if some keys from inner are existed or not. Can I do that ? Hopefully this won't be the only solution
&lt;code&gt;
if ( $x-&gt;{Y} ) {
  if ( $x-&gt;{Y}{Z} ) {
    1 if ( $x-&gt;{Y}{Z}{A} ) ;
  }
} ; # $VAR={};
&lt;/code&gt;

Any clues? Thank you very much!

</field>
</data>
</node>
