in reply to Re^3: Comparing pattern
in thread Comparing pattern
In that case, you need to read the data file in slurp mode:example 1: blah (foobar) blah example 2: blah (foo all sorts of content on lots of lines of data bar) blah
Regarding the placement of parens and regex qualifiers, you could do that in other ways, like: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... }
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.my $list_regex = qr/($regex_string)/is; ... if ( /$list_regex/ ) { ...
|
|---|