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