Keep It Simple, Stupid | |
PerlMonks |
Re: hash assignment wierdnessby Obidan (Initiate) |
on Apr 20, 2007 at 18:06 UTC ( [id://611214]=note: print w/replies, xml ) | Need Help?? |
The issue is that undef nulls out it's arguments and then returns a scalar value. when you assign something undef, it is not really the *absence* of a value, it is a reserved scalar that perl uses to indicate absence of genuine data. Digging into hash_file.c would most likely reveal that the hash operators make no special case for undef, and treats it as it would any other scalar value in assignmets. So as far as perl is concerned, when you assign undef to a hash, you're asking it for a hash containing the undef value. As far as I am aware, the only way to null out a hash is to use it as an argument to undef, as in your example code. Obidan :wq
In Section
Seekers of Perl Wisdom
|
|