in reply to Re^3: Comparing pattern
in thread Comparing pattern

You say that you "need /s so . to match newlines as well", and I assume this means that if your pattern list includes something like foo.*?bar, you would want that to match either of the following examples (where I'll put parens around the intended match):
example 1: blah (foobar) blah example 2: blah (foo all sorts of content on lots of lines of data bar) blah
In that case, you need to read the data file in slurp mode:
my $regex_string = join '|', @list_patterns; open( FILE, "<", $arg1 ) or die "$arg1: $!"; $_ = do { local $/; <FILE> }; # temporarily set $/ = undef to slurp f +ile close FILE; if ( /($regex_string)/is ) { # got a match... }
Regarding the placement of parens and regex qualifiers, you could do that in other ways, like:
my $list_regex = qr/($regex_string)/is; ... if ( /$list_regex/ ) { ...
No difference, really, but when there's a choice, I like having the parens visible in the code near the place where I use $1, $2, etc.