skyworld_chen has asked for the wisdom of the Perl Monks concerning the following question:
I would like to test if a directory exists. If not, mkdir it. I wrote code like this:
#!/usr/bin/perl if (! -d abc) { mkdir "abc", "0777" or die "Can't mkdir abc: $!"; }
I guess if the directory exist, there would prompt nothing. But it is interesting that the linux prompts "Can't generate abc: File exists". Can anybody help me to understand why the code still want to mkdir even if (! -d abc) implies false? thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mkdir usage
by BrowserUk (Patriarch) on Dec 21, 2012 at 02:02 UTC | |
|
Re: mkdir usage
by toolic (Bishop) on Dec 21, 2012 at 02:07 UTC | |
by frozenwithjoy (Priest) on Dec 21, 2012 at 05:45 UTC | |
|
Re: mkdir usage
by jwkrahn (Abbot) on Dec 21, 2012 at 05:25 UTC | |
|
Re: mkdir usage
by LanX (Saint) on Dec 21, 2012 at 02:25 UTC | |
by skyworld_chen (Acolyte) on Dec 21, 2012 at 02:37 UTC | |
|
Re: mkdir usage
by 2teez (Vicar) on Dec 21, 2012 at 02:11 UTC | |
|
Re: mkdir usage
by Marshall (Canon) on Dec 21, 2012 at 06:37 UTC | |
by Marshall (Canon) on Dec 21, 2012 at 06:54 UTC |