If I am reading this correctly (which I am probably not!) you need another foreach loop in there somewhere. When you compare $file with $lines, you are trying to compare the contents of @temp. I think you need to wrap your comparison with a foreach loop:

foreach $file (sort readdir (DH)) {
        foreach $lines(@temp) {
                if ($file eq $lines) {
                        etc etc
                }
        }
}

HTH

Dave
,
On Tuesday, July 8, 2003, at 11:22  pm, Sara wrote:

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);

#######################################




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to