@matches= $string =~ /$regex/gk; #### #!/usr/bin/perl -w use strict; use Benchmark qw( timethis cmpthese ); my %t; my $pref= "no&"; my $str= "match" . ( "garbage" x 500 ); for( 0, 1 ) { $t{$pref."?:"}= timethis( -3, sub { $str =~ /(?:match)+/; } ); $t{$pref."()"}= timethis( -3, sub { $str =~ /(match)+/; } ); eval '$&'; $pref= "amp"; } cmpthese( \%t ); __END__ Rate amp() no&() amp?: no&?: amp() 439813/s -- -0% -1% -81% no&() 441612/s 0% -- -0% -81% amp?: 443563/s 1% 0% -- -81% no&?: 2354611/s 435% 433% 431% --