$s = 'ab'x 10e6;; cmpthese -1, { a => q[ my $n = 0; while( $s =~ m[ab]g ){ $n++ }; ], b=>q[ my $n = 0; ++$n while $s =~ m[ab]g; ], };; s/iter a b a 2.31 -- -37% b 1.45 59% --