PERL: Determine if a folder/file exists?

michaelsanford

Translator, Web Developer
I seem to remember seeing somewhere in a sh or pl script, syntax similar to

IF EXIST $folder {
&install;
} else {
&create_folder;
&install;
}

Or something to that effect, but not that exactly.

I need to know how to determine if a file or folder exists on the system (I can pass it the absolute path, so I can check for mounted volumes with known names especially).

Thanks!
 
Give this a try --

if (-e $folder) {
&install;
} else {
&create_folder;
&install;
}

But it's better written like this (TMTOWTDI):

unless (-e $folder) {&create_folder}
&install;

 
Back
Top