iLTC Home
Bookmark iLTC!
iLTC Google Boards

Categories

Perl
  • Perl Tutorials Beginners

    Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

    HTML
  • HTML Tutorials



  • iLoveTheCode.com
    Perl > Perl Tutorials How To Easy > Check for Existing File in Perl

    Check for Existing File in Perl



    To see if a file already exists:

    if (-e "../cities.txt") {
    print "File exists!";
    }
    else {
    print "File does not exist.";
    }


    -We use -e to check for the file.
    -We enclose the path to the file in quotation marks. In this instance, one directory up is where we want to look for our file cities.txt so we use ../
    -We print the results of our checking.



    Copy and Paste Perl Code:

    #!/usr/bin/perl

    print "Content-type:text/html\n\n";

    if (-e "../cities.txt") {
    print "File exists!";
    }
    else {
    print "File does not exist.";
    }

    exit;


    Resources:
    To See if a Directory Exists in Perl
    If, Elsif, and Else in Perl


    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Getting What is Matched in Perl
    Next Article: To See if a Directory Exists in Perl





    CSS MasteryCSS Mastery

    Andy Budd, Simon C...

    New $23.09

    Struts 2 in ActionStruts 2 in Action

    Don Brown, Chad Da...

    New $29.69

    CSSCSS

    Eric Meyer

    New $29.69

    Dreamweaver CS3Dreamweaver CS3

    David McFarland

    New $29.69

    Head First HTML with CSS...Head First HTML with CSS & XHTML

    Eric Freeman, Elis...

    New $26.39

    HTML, XHTML, and CSS, Si...HTML, XHTML, and CSS, Sixth Edition ...

    Elizabeth Castro

    New $23.09

    HTML, XHTML, and CSS All...HTML, XHTML, and CSS All-in-One Desk...

    Andy Harris, Chris...

    New $23.09

    Beginning Joomla!Beginning Joomla!

    Dan Rahmel

    New $29.69


    Of Interest:
  • Add to End of an Array with Push in Perl
  • OPEN and WRITE a Data File in Perl
  • Delete a File Using unlink in Perl
  • Passing a Variable or Value to a Subroutine in Perl
  • Use onLoad in Body Tag with Javascript
  • Use onLoad to Call More than One Function with Javascript
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • If, Else If, and Else in Javascript
  • HTML Link
  • HTML Underline Text
  • Make a Line Return Using HTML
  • Make Text Bold Using HTML

  • More Articles:
  • OPEN and WRITE a Data File in Perl
  • OPEN and READ a Data File in Perl
  • Passing a Variable or Value to a Subroutine in Perl
  • Encryption with the Crypt Function in Perl
  • onClick Javascript
  • Passing an Argument or Variable to a Javascript
  • PRINT to Browser with document.write Command in Javascript
  • Use onLoad to Call More than One Function with Javascript
  • Use onClick in Javascript
  • HTML Codes
  • HTML Color Codes
  • HTML Tags
  • HTML Subscript Text

  • Search iLTC w/ Google





    Recent Articles

  • Javascript Focus Form Field
  • Javascript Lowercase Text
  • Javascript Uppercase Text
  • Javascript Superscript Text
  • Javascript Subscript Text
  • Make Text Blink Using Javascript
  • Make a String into a Link in Javascript
  • Javascript Italics Text
  • Javascript Bold Text
  • Javascript Redirect
  • HTML Frames
  • HTML Color Chart
  • HTML Link
  • Javascript Status Bar








  • Perl Programming - Javascript Programming - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006 iLoveTheCode.com


    Contact Chris | About this Site


    581,337
    Counter by iLoveTheCode.com


    Last Modified: Friday, 23-Jun-2006 07:23:12 EDT