|
-
Feb 28th, 2002, 06:23 PM
#1
Thread Starter
Stuck in the 80s
FileExists?
Is there a way to tell if a file exists in Perl?
-
Feb 28th, 2002, 06:30 PM
#2
Frenzied Member
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...
Code:
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Mar 1st, 2002, 12:44 PM
#3
Black Cat
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'}");
works fine for me with ActivePerl.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|