use strict; use warnings; my @strings = qw(exception:tex exception:mex asdf tex:exception:mex); for ( my $i; $i < 500; $i++ ) { my @unfiltered = @strings; my @filtered = grep { /exception:(?!tex)/} @unfiltered; }; my @unfiltered = @strings; my @filtered1 = grep { /exception/ && !/tex/ } @unfiltered; }; my @unfiltered = @strings; my @filtered2 = grep { /exception:/g && !/\Gtex/ } @unfiltered; }; }