use strict; use warnings; use Benchmark qw(cmpthese); my $key = 'x'; my $str = ("\n The quick brown frog jumped over the lazy dog" x 10000) . "\n x"; cmpthese (-10, { sol => \&sol, nl => \&nl, lb => \&lb, } ); sub sol {$str =~ /^ \s* $key /mx;} sub nl {$str =~ /\n \s* $key /mx;} sub lb {$str =~ /(?