use strict; use warnings; use Benchmark; my @strings = qw(exception:tex exception:mex asdf tex:exception:mex); Benchmark::cmpthese( -5, { 'one' => sub { my @filtered = grep { /exception:(?!tex)/} @strings; }, 'two' => sub { my @filtered = grep { /exception/ && !/tex/ } @strings; }, 'three' => sub { my @filtered = grep { pos = 0; /exception:/g && !/\Gtex/ } @strings; }, }); __END__ Rate three one two three 99554/s -- -18% -38% one 121692/s 22% -- -24% two 161067/s 62% 32% --