in reply to extracting splices with a for-loop and splice()

Update: Roy Johnson already said as much over here.

You won't need the special $match logic if you scan @$stuff backwards. An untested revision of your original function:

sub filter_stuff { my ($stuff, @patterns) = @_; my $i = @$stuff; while ($i--) { for (@patterns) { next unless $stuff->[$i] =~ /$_/; splice(@$stuff, $i, 1); last; } } }

When splice() removes an item, all the others with higher indexes move down. The loop has already checked $i+1 when it moves into position $i, so you can move on without checking it again.

-- Rocco Caputo - rcaputo@pobox.com - poe.perl.org