PDA

Click to See Complete Forum and Search --> : FileExists?


The Hobo
Feb 28th, 2002, 05:23 PM
Is there a way to tell if a file exists in Perl?

CiberTHuG
Feb 28th, 2002, 05:30 PM
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...


if (-e $fileName) {
&mojo
}


'Course, that might not be implimented in ActivePerl. *shrug*

You can try www.perlmonks.org if you don't have a Camel (or Llama) around.

JoshT
Mar 1st, 2002, 11:44 AM
#make sure there's not a file by that name already there
push @errors, "File already exists: " . $form{'filename'} if (-e "files/$form{'filename'}");

works fine for me with ActivePerl.