my @patterns=qw/foo bar baz blarch/; my $tilly=qr/(@{[join "|",@patterns]})/; my @chetlin=map qr/$_/,@patterns; my $target="foo baz blarcy foo blarch"x400; sub tilly { my $count; $count++ while ($target =~ /$tilly/g); print STDERR "tilly gives: $count\n" if ((caller)[1]!~/eval/); } sub chetlin { my $count; for (@chetlin) {$count++ while ($target =~ /$_/g) } print STDERR "chetlin gives: $count\n" if ((caller)[1]!~/eval/); } tilly(); chetlin(); use Benchmark; timethese(-5, { tilly => \&tilly, chetlin => \&chetlin, });