<?xml version="1.0" encoding="windows-1252"?>
<node id="315063" title="Deleting hash entry" created="2003-12-16 09:53:59" updated="2005-06-04 01:49:01">
<type id="115">
perlquestion</type>
<author id="126161">
hotshot</author>
<data>
<field name="doctext">
hello guys!&lt;BR&gt;&lt;BR&gt;
I have a hash of hashes, for example:&lt;CODE&gt;
%hash = {
         abc =&gt; {
                 def =&gt; 1,
                },
         ghi =&gt; {
                 jkl =&gt; 1,
                },
};
&lt;/CODE&gt;
What happen if I do:&lt;CODE&gt;
delete($hash{abc}{def});
&lt;/CODE&gt;
am I staying with?:&lt;CODE&gt;
%hash = {
         abc =&gt; undef,
         ghi =&gt; {
                 jkl =&gt; 1,
                 mno =&gt; 1,
                },
};
&lt;/CODE&gt;
That was the first question.&lt;BR&gt;
My second one is, I'm looping over the hash and delete keys as shown above if fulfilled a condition. If the ansewer to the first question is yes, is there a short way to delete also the first level key ('abc' in the example) when deleted all second level keys under it. In the example, when performing the above &lt;I&gt;delete&lt;/I&gt;, i would have like to stay with:?:&lt;CODE&gt;
%hash = {
         ghi =&gt; {
                 jkl =&gt; 1,
                 mno =&gt; 1,
                },
};
&lt;/CODE&gt;
Thanks
&lt;BR&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-126161"&gt;
&lt;BR&gt;&lt;BR&gt;
&lt;A HREF="/index.pl?node=Hotshot&amp;lastnode_id=1072"&gt;Hotshot&lt;/A&gt;
&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
