christophermichael
Programmer
I am having difficulty with a file exist problem. Below is my code and an explanation of my problem.
I have files in a directory which are the saved as the array @files. I know that this is working fine as I've used it MANY times with success.
Throughout the script each file is refered to as @files[0]. The URL passes along a file number (script.cgi?file=0) so that @files[$file] will return the name of the first file in the directory.
Then I have this piece:
$next = $file + 1;
Meaning that the next file will be the next file in @files.
Here is my exist:
if (-e "./directory/@files[$next]") {
print 'File exists.';
}else{
print 'File does not exist.';
}
Now this keeps returning true no matter what file number I put into the string such as script.cgi?files=10 will return true even if there are only 4 files in the directory.
I did a horrible job of explaining this so please ask for clarification if you need it.
THANKS A TON.
And Merry Christmas Eve =0)
I have files in a directory which are the saved as the array @files. I know that this is working fine as I've used it MANY times with success.
Throughout the script each file is refered to as @files[0]. The URL passes along a file number (script.cgi?file=0) so that @files[$file] will return the name of the first file in the directory.
Then I have this piece:
$next = $file + 1;
Meaning that the next file will be the next file in @files.
Here is my exist:
if (-e "./directory/@files[$next]") {
print 'File exists.';
}else{
print 'File does not exist.';
}
Now this keeps returning true no matter what file number I put into the string such as script.cgi?files=10 will return true even if there are only 4 files in the directory.
I did a horrible job of explaining this so please ask for clarification if you need it.
THANKS A TON.
And Merry Christmas Eve =0)