Abigail is (as usual) correct. However, if I were doing this, I'd code that as:
my $goodnames = qr/@{[join '|', map "\Q$_", sort @names]}/;
Or, if I were golfing:
my $goodnames = qr/@{[join'|',map"\Q$_",sort@names]}/;
;-)
And, if I were going to be interpolating arrays into regexes on a regular basis, I'd probably modularize the process thus:
use Interpolation
OR => sub { join '|', map "\Q$_", sort @{$_[0]} };
# and later...
my $goodnames = qr/$OR{\@names}/;
BTW, arrays will interpolate disjunctively in Perl 6, so eventually you'll be able to just write:
# Perl 6 code
my $goodnames = /@names/;
Yet another feature for Abigail to not be impressed by, I guess. ;-) |