in reply to Re: how do I efficiently remove one hash from another?
in thread how do I efficiently remove one hash from another?

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.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^3: how do I efficiently remove one hash from another?
by ColonelPanic (Friar) on Nov 28, 2012 at 14:25 UTC
    The slice option only calls delete once. It also doesn't have to go the trouble of assigning $_ for each element. So that makes sense.


    When's the last time you used duct tape on a duct? --Larry Wall