if you want to match only if the three lines are excatly xxxxx, yyyyy and zzzzz respectivly, remove the .*? from the regexuse strict; use warnings; #slurp mode, read whole file in one variable $/ = undef; my $text = <DATA>; if ($text =~ /xxxxx.*?\n.*?yyyyy.*?\n.*?zzzzz/) { print "match \n"; } else { print "no match \n"; } __DATA__ xxxxx bla yyyyy bla bla zzzzz
In reply to Re: regex on previous lines
by si_lence
in thread regex on previous lines
by MacScissor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |