in reply to OT: clearing a hash (was: TIMTOWTDI doesn't mean invent an outlandish approach (usually))
in thread TIMTOWTDI doesn't mean invent an outlandish approach (usually)
It'll create a one element hash, whose key is the empty string, with an undefined value.$ 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
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: OT: clearing a hash
by Aristotle (Chancellor) on Oct 13, 2003 at 11:04 UTC | |
by Abigail-II (Bishop) on Oct 13, 2003 at 11:36 UTC |