use strict; use warnings; use Benchmark; my @strings = qw(exception:tex exception:mex asdf tex:exception:mex); my @one = @strings; my @two = @strings; my @three = @strings; Benchmark::cmpthese( -5, { 'one' => sub { my @filtered = grep { /exception:(?!tex)/} @one; }, 'two' => sub { my @filtered = grep { /exception/ && !/tex/ } @two; }, 'three' => sub { my @filtered = grep { /exception:/g && !/\Gtex/ } @three; }, });