The '%hash = undef' is incorrect:
$ perl -wle '%hash = undef; print scalar %hash'
Odd number of elements in hash assignment at -e line 1.
Use of uninitialized value in list assignment at -e line 1.
1/8
It'll create a one element hash, whose key is the empty string, with an undefined value.
The last three solutions modify the hash while iterating
over the keys, which should be a no-no. However, I just
read that in the documentation of 'each' that deleting
the item most recently returned by 'each()' is safe; this
feature seems to have been added (or documented) in 5.6.1.
Abigail