laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I agree that a documentation patch is the best response. Since the value for a key can be literally any scalar, it is impossible to think of a return value that would serve to distinguish between the two cases (at least without some perl magic). We can imagine delete returning a hash or a list of key-value pairs, but (besides breaking compatibility) that would injure idioms that are more useful than knowledge of which keys existed before a deletion. The idiom for re-keying a value, $foo{'bar'} = delete $foo{'baz'}; would be wrecked, for instance. A workaround can be devised pretty easily if we need the existence information, my @actual_values = delete @a{ grep { exists $a{$_}} @somekeys}; There are lots of variations possible on that snippet. After Compline, In reply to Re: Deleting undef values from a hash
by Zaxo
|
|