$ cat t.pl #!/usr/bin/perl use strict; use warnings; my $t; { # A: Slurp in the entire file local $/; $t = ; } # B: Scan the entire file for a lines containing either # of the words 'fox' or 'wood', and print them. print "<$_>\n" for $t=~/^(.*?(?:fox|wood).*?)$/gm; __DATA__ Now is the time for all good men to come to the aid of their party. The quick red fox jumped over the lazy brown dog. How much wood can a woodchuck chuck? If a woodchuck could chuck wood? $ perl t.pl