in reply to Good Idiom for Matching List?
That's a good point. I've never used array interpolation in a regex and, when I've run into it, it was usually accidental (and broke things). I've occasionally wondered why it was implemented in the first place.
We already do special processing of interpolation in a regex and \Q already treats interpolation specially. So it'd be really cool if /(@x|\Q@y\E)/ defaulted to being the same as /(${\join"|",@x,map(quotemeta,@y)})/ instead of the rather silly /(${\join($",@x)}${\quotemeta(join($",@y))})/ That is
should be the same as the useful /(:|;|-|\.|\||\?)/ not the silly /(: ; -|\.\ \|\ \?)/ that is, use "|" in place of $" and have \Q not escape it. - tyemy @x= qw( : ; - ); my @y= qw( . | ? ); /(@x|\Q@y\E)/
|
|---|