use strict; use warnings; open (my $fh, "<", "testlines.txt") or die "$!"; local $/ = "\n\n"; while (<$fh>) { if ($_=~ /(third | four)/si) { chomp; print "line is: $_\n"; } } close $fh; #### Code>perl test15.pl line is: This is line one. Line Two is this. Third line starts here. This is line four.