Is there a way to tell if a file exists in Perl?
Printable View
Is there a way to tell if a file exists in Perl?
I've never done this, so don't quote me. I always just try to open the file, and if that fails, then maybe the file didn't exist.
But...
'Course, that might not be implimented in ActivePerl. *shrug*Code:if (-e $fileName) {
&mojo
}
You can try www.perlmonks.org if you don't have a Camel (or Llama) around.
works fine for me with ActivePerl.Code:#make sure there's not a file by that name already there
push @errors, "File already exists: " . $form{'filename'} if (-e "files/$form{'filename'}");