in reply to how do I efficiently remove one hash from another?
Whether the loop is explicit, or implicit, there's a loop. But one cool means is:
delete @hash1{ keys %hash2 };
...which is pretty much the same thing as...
delete $hash1{$_} for keys %hash2;
...but with an implicit loop (via the hash slice) rather than the explicit 'for' loop. Note in either case, there's no need to worry about checking exists: delete doesn't complain if the element doesn't already exist.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how do I efficiently remove one hash from another?
by tobyink (Canon) on Nov 27, 2012 at 10:26 UTC | |
by ColonelPanic (Friar) on Nov 28, 2012 at 14:25 UTC | |
|
Re^2: how do I efficiently remove one hash from another?
by perltux (Monk) on Nov 27, 2012 at 07:18 UTC |