The problem with this is that you have to compile a new regular expression for every line of $input. You can do this sort of alternation in a regular expression like
my @patterns = qw/ test good /; my $alt = join('|', @patterns); my $re = qr/(?:$alt)/; while (<DATA>) { if ( /$re/ ) { print "+ $_"; } else { print "- $_"; } } __END__ THis is a test this is only a test now is the time for all good men to come to the aid of their country.
Other than perlop and perlre, a good place to look for regular expressions is the Jeffery Friedl book, Mastering Regular Expressions.
In reply to Re: Re: More than one regexp.
by eg
in thread More than one regexp.
by onion2k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |