# never forget the following!!! use strict; use warnings; # use diagnostics; # this can be skipped but is useful when starting # grab user input.. # choose a file name for the out file.. ... open my $readhandle, '<', $filetoread or die "Unable to read [$filetoread]!"; open my $writehandle '>', $filetowrite or die ""Unable to write [$filetoread]!"; # not <> but a named lexical filehandle while (<$readhandle>){ if ($_ =~ /somethingtosearch/){ # print to the write file print $writehandle $_; } } # always explicitally close filehandle: Perl will normally does the right thing but it is safer to close them anyway (good habit) close $readhandle; close $writehandle; # take the file and attach to an email ...