Perl: Two different outputs as to whether a file exists
Posted: Fri May 02, 2008 11:33 am
I've been programming PHP for a few years but my employer now wants me to learn Perl as well.
This is a simple perl script that checks to see if a file exists. The file is in the same directory as the perl script below. The script is simple and straightforward but it's the results that aren't making sense to me.
Here is where I'm lost.
Browser Output: "File doesn't exist for some reason"
SSH output: "File exists"
So when I run "perl perlfile.pl" via SSH it says the file exists. However, the browser output says otherwise.
Any thoughts?
This is a simple perl script that checks to see if a file exists. The file is in the same directory as the perl script below. The script is simple and straightforward but it's the results that aren't making sense to me.
Code: Select all
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$file = "ccv.html";
if (-e "$file"){
print "File exists";
} else {
print "File doesn't exist for some reason";
}
Browser Output: "File doesn't exist for some reason"
SSH output: "File exists"
So when I run "perl perlfile.pl" via SSH it says the file exists. However, the browser output says otherwise.
Any thoughts?