Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Creating new folders

by Anonymous Monk
on Feb 03, 2008 at 10:57 UTC ( #665808=note: print w/replies, xml ) Need Help??


in reply to Re: Creating new folders
in thread Creating new folders

In general I try very hard to avoid the race condition that come from assuming the result of a filetest operator remains valid. In this case it is possible that something creates the directory between the moment of the -d and the mkdir and that's a case I'd prefer to work instead of fail. In many real cases this is impossible or not an issue of course, but I still prefer my code to be able to handle such cases. So normally I'd write:
if (!mkdir($dir)) { my $err = $!; die "Could not create $dir: $err" unless -d $dir; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://665808]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2021-10-16 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (69 votes). Check out past polls.

    Notices?