What's the best way to tell if a file exists in a directory?

Posted by Nano HE on Stack Overflow See other posts from Stack Overflow or by Nano HE
Published on 2010-03-24T08:45:07Z Indexed on 2010/03/24 10:53 UTC
Read the original article Hit count: 234

Filed under:
|
|

I'm trying to move a file but I want to ensure that it exists before I do so. What's the simplest way to do this in Perl?

My code is like this. I looked up the open command, but I am not sure it is the simplest way or not.

if  #Parser.exe exist in directory of Debug
{
    move ("bin/Debug/Parser.exe","Parser.exe");
}
elsif  #Parser.exe exist in directory of Release
{
    move ("bin/Release/Parser.exe","Parser.exe");
}
else
{
    die "Can't find the Parser.exe.";
}

Thank you.

© Stack Overflow or respective owner

Related posts about perl

Related posts about directory