in reply to Clean out da hash...
Quote from perldoc -f each
If you add or delete elements of a hash while you're iterating over it, you may get entries skipped or duplicated, so don't. Exception: It is always safe to delete the item most recently returned by "each()", which means that the following code will work:
while (($key, $value) = each %hash) { print $key, "\n"; delete $hash{$key}; # This is safe }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Clean out da hash...
by davido (Cardinal) on Feb 12, 2004 at 17:02 UTC | |
by GaijinPunch (Pilgrim) on Feb 13, 2004 at 00:19 UTC |