perl -MBenchmark -w ($s, $t) = qw/ foo xfoox /; timethese(-1, { oful => q{ $t =~ /$s/o }, oless => q{ $t =~ /$s/ }, }) __END__ Benchmark: running oful, oless for at least 1 CPU seconds... oful: 2 wallclock secs ( 1.08 usr + 0.00 sys = 1.08 CPU) @ 2427258.33/s (n=2621439) oless: 2 wallclock secs ( 1.15 usr + 0.00 sys = 1.15 CPU) @ 1841144.35/s (n=2117316)