Wednesday, March 11, 2009

How to check if a directory exists in perl?

how to check if a directory exists in perl?

How to tell if a file exists in perl?

#!/usr/bin/perl -w

$filename = '/path/to/your/file.doc';
if (-e $filename) {
print "File Exists!";
}

that the file does not exist - by using the unless conditional:

unless (-e $filename) {
print "File Doesn't Exist!";
}