########################## my $directory = 'C:\'; opendir(DIR, $directory); my @files = grep { $_ ne '.' && $_ ne '..' } readdir DIR; closedir(DIR); # storing all file names in the folder in an array foreach(@files){ print $_,"\n"; } # emailsent.txt-will contain the name of all files for whom an alert has been sent # emailtogo.txt-will contain the name of all new files for whom an alert has to be sent my $matchfile = 'emailsent.txt'; my $outfile = 'emailtogo.txt'; open (IN, ">>$matchfile"); open (OUT, ">>&outfile"); # Comparing the array to the names in $matchfile foreach(my $file = @files){ for my $file2(){ if ($file ne $file2){ print OUT $file;} } #Insert names to original text file my @files = ; foreach(@files){ print IN, "\n"; } close(IN); close(OUT);