use Benchmark(cmpthese); cmpthese(1000000, { 'a' => sub { $_ = 'this that this those this these.'; $a = () = /this/g; }, 'b' => sub { $_ = 'this that this those this these.'; $a++ while(s/this//); }, 'c' => sub { $_ = 'this that this those this these.'; $a = s/this/this/g; } }); #### Rate a b c a 478240/s -- -4% -19% b 497018/s 4% -- -16% c 588235/s 23% 18% --