I m trying to read the files in a directory and match them with a same file names in text list.
Below given are the couple of lines, but I am unable to get the results, rather getting the same line repeated This fileno1 does NOT found in directory but its in the list This fileno2 does NOT found in directory but its in the list This fileno3 does NOT found in directory but its in the list and so on.... So its matching the file names but not giving the desired results? Any idea? ################################### open (NO, "list.txt"); # A list that contains the file numbers in a txt file, one per line @temp = <NO>; foreach $lines(@temp){ chomp $lines; } $dir = "Test"; #Directory we are opening to match the files in the directory with the above given list. opendir (DH, $dir) || die ("could not open directory $dir\n"); foreach $file (sort readdir (DH)) { if ($file eq $lines) { print "<br>This $file exists and found in the list too $lines"; } else { print "<br>This $file does NOT found in directory but its in the list"; } } close (DH); #######################################