How to tell if a file exists in Perl:
If you want to check the file is exist or not means simply add the '-e' behind the file name.
For example:
$filename = '/path/to/your/file.doc';
if (-e $filename)
{
print "File Exists!";
}
You want to check it file not exist means use 'unless' or '!' operator.
For Example:
unless (-e $filename)
{
print "File Doesn't Exist!";
}
No comments:
Post a Comment