while (my $line = <$fh>){ if ($line =~ /From\:/ && $line =~ /Subject\:/) { print $line; } }