my %things = (foo => sub {print "skipping foo\n"; next}, bar => sub {handle_bar($_); next}, ); for (@some_array) { (delete $things{$_})->() if exists $things{$_}; handle_rest($_); }