Results 1 to 3 of 3

Thread: FileExists?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    FileExists?

    Is there a way to tell if a file exists in Perl?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.

  3. #3
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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
  •  



Click Here to Expand Forum to Full Width