Wednesday 23 September 2015

Check the Existence of a File Using Perl

A simple Perl script to check the existence of the file in the destination place.

Perl Code: 
#check the existence of the file if yes say file exists else terminate the program
$filename = 'G:\\GPB\\protoc-3.0.0-alpha-3-win32\\protoc.exe';
 if (-e $filename)
 {
    print "File Exists!";
 }
 else
 {
    die ("$!\n");   
 }



OutPut:

 > perl CheckExsistenceOfFile.pl
 File Exists!

No comments:

Post a Comment