in reply to Is there a -e test for directories, like there is for files?
-e does return true for directories (and any other kinds of file).
-f checks only for plain files.
-d checks only for directories.
But do you really need to check if the dir exists? You could just try to make the directory unconditionally.
# Try to make the directory in case it doesn't exists. mkdir($dir); # or mkpath($dir); opendir($dir) or die("Unable to open dir \"$dir\": $!\n"); ...
You might be interested in (core module) File::Path's mkpath instead of mkdir. It creates intermediary directories as needed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a -e test for directories, like there is for files?
by mdunnbass (Monk) on Feb 08, 2007 at 20:41 UTC | |
by ikegami (Patriarch) on Feb 08, 2007 at 20:55 UTC | |
by mdunnbass (Monk) on Feb 08, 2007 at 21:15 UTC | |
by johngg (Canon) on Feb 08, 2007 at 23:51 UTC | |
by ikegami (Patriarch) on Feb 08, 2007 at 21:18 UTC | |
by ikegami (Patriarch) on Feb 08, 2007 at 21:00 UTC | |
by mdunnbass (Monk) on Feb 08, 2007 at 21:06 UTC |