use Benchmark; my @words = map { chomp; $_ } (); my $alpha = '[a-zA-Z]'; my $alnum = '[a-zA-Z0-9]'; my @qr = ( qr/^$alpha/, qr/$alnum+$/ ); timethese(500000, { 'With /o' => \&testsub, 'qr' => \&testsubqr, }); sub testsub{ my $count = 0; foreach(@words){ $count += testsubb($_); } } sub testsubb { my $word = $_[0]; return unless $word =~ /^$alpha/o; return unless $word =~ /$alnum+$/o; return 1; } sub testsubqr{ my $count = 0; foreach(@words){ $count += testsubbqr($_); } } sub testsubbqr { my $word = $_[0]; foreach(@qr){ return unless $word =~ $_; } return 1; } Benchmark: timing 500000 iterations of With /o, qr... With /o: 12 wallclock secs (13.13 usr + 0.01 sys = 13.14 CPU) @ 38051.75/s (n=500000) qr: 18 wallclock secs (18.90 usr + 0.01 sys = 18.91 CPU) @ 26441.04/s (n=500000) Benchmark: timing 100000 iterations of With /o, qr... With /o: 3 wallclock secs ( 2.64 usr + 0.00 sys = 2.64 CPU) @ 37878.79/s (n=100000) qr: 4 wallclock secs ( 3.78 usr + 0.00 sys = 3.78 CPU) @ 26455.03/s (n=100000)