use Benchmark('countit'); $code = '$str =~ s/(?<=[a-z])(?=[A-Z])/_/g'; $t = countit(5, '$str="BuyACaseOfCamels";' . $code); $count = $t->iters ; print "$count loops of $code\n"; $code = '$str =~ s/([a-z]+)(?=(.?))/ $1 . (length($2) ? "_" : "") /ge'; $t = countit(5, '$str="BuyACaseOfCamels";' . $code); $count = $t->iters ; print "$count loops of $code\n"; $code = '$str =~ s/([a-z]+)/$1_/g; $str =~ s/_$//'; $t = countit(5, '$str="BuyACaseOfCamels";' . $code); $count = $t->iters ; print "$count loops of $code\n";