use Benchmark 'cmpthese'; our $orig = "a" x 20; $orig .= ""; $orig .= "a" x 20; $orig .= ""; $orig .= "a" x 20; cmpthese(-1, { 's///' => 'my $c = $orig; $c =~ {}{XXXX}g;', substr => 'my $c = $orig; while ((my $i = index($c, "")) > -1) { substr($c, $i, 17) = "XXXX"; }' }); __END__ Rate substr s/// substr 240498/s -- -37% s/// 381869/s 59% --