$s = join'', map{ chr( 65+rand(26) ) x rand( 100 ) } 1 .. 1000;; cmpthese -1,{ a=>q[ 1 while $s =~ m[((?=(.))\2+)]g; ], b=>q[ 1 while $s =~ m[((?=(.))\2+)]mg; ] };; Rate a b a 203/s -- -1% b 205/s 1% --