Perl has the ability to automatically bring a new key into existence when you assign something to it without the need for that key to have been created beforehand - this is true in n-dimensional hash structures also. So in many situations, there is no need to make an "undef" value for a key or even to create that key. Sometimes there is a need ("in many situations" does definitely not mean "in all situations").
I am just curious as to why you want to do this?
Update: I am not saying that anything in the other posts is wrong - quite the contrary - there are some excellent formulations of how to do this. Grandfather's stuff looks fantastic to me. I'm just saying that often it is not necessary to set a whole bunch of keys to "undef" in the first place. Maybe in this application it is warranted. But if its not needed, then there can be some simplifications.
In reply to Re^2: How to create a hash whose values are undef?
by Marshall
in thread How to create a hash whose values are undef?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |