Hello,
I want to check whether a certain list of files exist in a directory.
I have the following code
I know the file exists in the directory. But, the above code always prints file does not exist. Unable to fix this. The same code works fine if I include the filename in the following line instead of the variable.
Thanks
I want to check whether a certain list of files exist in a directory.
I have the following code
Code:
@lines = <SOURCE>;
foreach $line (@lines) {
chomp;
print $line\n;
chdir ("i:/FIDESSA/diva/divafiles");
if (-e 'i:/fidessa/diva/divafiles/$line') {
print "File $line exists\n";
} else {
print "Oh no $line doesn't exist today!\n";
}
}
I know the file exists in the directory. But, the above code always prints file does not exist. Unable to fix this. The same code works fine if I include the filename in the following line instead of the variable.
Code:
if (-e 'i:/fidessa/diva/divafiles/FID001.pdf') {
print "File $line exists\n";
}
Thanks