######################
open (DATA, "data.txt") || die "Cannot open file. Reason: $!";
@data = <DATA>;
close(DATA);
open (LIST, "list.txt") || die "Cannot open list.txt. Reason: $!";
while (<LIST>) {
$found = 0;
foreach $line (@data) {
chomp $line;
if ($line eq $_) { $found = 1; last; }
$found = 0;
}
if ($found) {
print "Entry \"$_\" was found in data.txt <BR>";
}
else
{
print "Entry \"$_\" was NOT found in data.txt <BR>";
}
}
#####################
list.txt (contains 3 enteries)
######
file1.html
file3.html
file2.html
######
data.txt (contains 2 enteries)
######
file3.html
file1.html
######
The script is generating the following output
Entry "file1.html " was NOT found in data.txt
Entry "file3.html " was NOT found in data.txt
Entry "file2.html " was NOT found in data.txt
though, file1.html and file2.html exists in data.txt
Any ideas what I m doing wrong?
I want to compare both text files and the script should produce that this. i.e after
comparing the file nos. it should report which file is found and which is not found.
file1.html was found in the data.txt
file2.html was NOT found in the data.txt
file3.html was foundi in the data.txt
TIA,
Sara.