use strict; use warnings; use Benchmark; our @strings = qw(exception:tex exception:mex asdf tex:exception:mex); Benchmark::cmpthese( -5, { 'one' => q[ my @unfiltered = @strings; my @filtered = grep { /exception:(?!tex)/} @unfiltered; ], 'two' => q[ my @unfiltered = @strings; my @filtered = grep { /exception/ && !/tex/ } @unfiltered; ], 'three' => q[ my @unfiltered = @strings; my @filtered = grep { /exception:/g && !/\Gtex/ } @unfiltered; ], }); __END__ Rate three one two three 81985/s -- -14% -24% one 95390/s 16% -- -12% two 108473/s 32% 14% --