The former compiles to a much smaller op tree than the latter:
perl -MO=Concise -e'delete @hash1{keys %hash2}' perl -MO=Concise -e'delete $hash1{$_} for keys %hash2'
On my machine, the slice performs about 20% faster than the loop.
In reply to Re^2: how do I efficiently remove one hash from another?
by tobyink
in thread how do I efficiently remove one hash from another?
by perltux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |