# Find lines starting with "_ and ending with ", and containing optional # leading or trailing whitespace. # my $MAL = '^\s*"_.*"\s*$'; #### use strict; use warnings; my $out = "Backup/backup.txt"; my $out2 = "nomatch.txt"; my $logfile = "log.txt"; my $MAL = '^\s*"_.*"\s*$'; open LOG, "<", $logfile or die "Cannot open $logfile for read :$!"; open OUT, ">$out" or die "Cannot open $out for write :$!"; open OUT2, ">$out2" or die "Cannot open $out2 for write :$!"; while ( ) { if ( $_ =~ /$MAL/i ) { print OUT $_; } else { print OUT2 $_; } }