in reply to File tests failing
If I use the test: if(-s $filename > 0) It never returns true.
Given that fact, one of the following must be true: (a) the file exists but its directory entry indicates that it contains zero bytes, or (b) the file does not exist.
I've also tried replacing -s with -e just to see if the true/false works and it never returns true.
This seems to indicate that the path/file named in $filename really does not exist, or can't be found given the current context of the script (e.g. permissions and/or current working directory).
Have you inspected the value stored in $filename to confirm that it contains the string you were expecting? If the string assigned to $filename is a relative file path, are you certain that the script's current working directory is the correct location to start from in order to follow that path?
The CGI program creates the file that it's attempting to size...
So you say, but suppose we ask you to prove that. Did you include "... or die ..." on the statements that opened, wrote and closed that file? (You did close it before trying "-s" on it, didn't you?)
Have you gone in with a command-line shell, "cd" to the directory in question, and check for the file yourself?
And in case you're still confused, look again at perldoc -f -X: -e returns 0 or 1 (false or true) according to whether a file exists; -s returns a number greater-than-or-equal-to zero, where zero could mean "non-existent" or "existent but empty".
|
|---|