Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Deleting hash entryby Aragorn (Curate) |
on Dec 16, 2003 at 15:22 UTC ( [id://315069]=note: print w/replies, xml ) | Need Help?? |
First of all, the notation %hash = { ... is wrong. You either assign a hash with %hash = ( ... or a hash reference with $hash = { .... Watch those parentheses and curly braces. See perlreftut and perlref for more information.
As for deleting: The second question: I don't know :-). Having an undefined hash value is perfectly valid, so the upper level is not automatically deleted when the lower level becomes undefined. You could add a statement like delete $hash->{$key} if not keys %{$hash->{$key}}. This deletes the key only if the hash it references is empty. Arjen
In Section
Seekers of Perl Wisdom
|
|