[denzil_cactus]: unless(-d $dir){ `mkdir $dir`;}is this code correct i +f I want to check the directory exists or not? [moritz]: use if (-d $dir) [ysth]: no, the -d could fail if you don't have access (but then you p +robably wouldn't be able to do the mkdir either [ysth]: and use perl's mkdir, not the shell [ysth]: mkdir [ysth]: err, I mean the -d could fail but the directory already exist [moritz]: yes, then use -e instead [moritz]: or whatever test you're feeling lucky with ;-) [ysth]: if you may need to create multiple levels of directory (say, c +reate foo/bar/baz where only foo exists), use File::Path::mkpath (in +an eval {} )
In reply to Re^2: problem in checking if directory exists
by denzil_cactus
in thread problem in checking if directory exists
by denzil_cactus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |