Perl 5 has been around for a while and has seen quite a bit of optimization. It's fast.
#!/usr/bin/env perl
use warnings;
use strict;
use Regexp::Assemble;
my $ra = Regexp::Assemble->new;
while (<>) {
chomp;
$ra->add($_);
}
print $ra->re . "\n"; my $re = join "|", @list;
my (@matches) = $txt =~ /$re/g;
Quicker and faster...