in reply to Re: Dynamic regexp from array values
in thread Dynamic regexp from array values

You *must* use quotemeta or \Q \E if you are going to do this and qr// or a /o modifier on the regex is also not a bad idea:

my $re = join '|', map{quotemeta}@vals; $re = qr/$re/; if ( $var =~ m/$re/ ) { blah }

If you fail to quotemeta then your regex will either die or commit weirdness if there are any / ( ) { } ^ $ * ? + \ - . chars present in @vals. quotemeta is a vital part of doing this.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print