in reply to Regular Expression

In case we search not only in the beginning:
use Benchmark; use strict; my $string = 'x' x 100; my $regex = qr{(?:abc|xyz)}; timethese 1_000_000 => { unanchored => sub { $string =~ /$regex/i }, anchored => sub { $string =~ /^(?=.*abc)(?=.*xyz)/i }, }; __END__ Benchmark: timing 1000000 iterations of anchored, unanchored... anchored: 1 wallclock secs ( 1.55 usr + -0.01 sys = 1.53 CPU) @ 65 +2741.51/s (n=1000000) unanchored: 19 wallclock secs (19.37 usr + 0.00 sys = 19.37 CPU) @ 51 +615.57/s (n=1000000)