in reply to Re: RegExp to Search All Array Members?
in thread RegExp to Search All Array Members?

An alternative to using join and string concatenation when making the pattern would be to change the default list separator from a space to the pipe symbol and use interpolation with the array or list.

$ perl -Mstrict -Mwarnings -le ' > my @arr = qw{abc d.ef gh?i}; > my $patt; > { > local $" = q{|}; > $patt = qq{xyz(@{ [ map quotemeta, @arr ] })123}; > } > print $patt;' xyz(abc|d\.ef|gh\?i)123 $

You can also use this method with qr{...} which behaves like double quotes.

Cheers,

JohnGG