Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: File::Path problem (will not create file if directory with same name exists)

by Monk::Thomas (Friar)
on May 19, 2014 at 15:25 UTC ( [id://1086673]=note: print w/replies, xml ) Need Help??


in reply to Re^2: File::Path problem (will not create file if directory with same name exists)
in thread File::Path problem (will not create file if directory with same name exists)

Hint: Create a file with a temporary filename in the correct location, write the file's content and attributes and if everything went well rename it into the correct filename. If something fails delete the file.

Of course you can create the tempfile somewhere else, but then the copy operation may fail (not enough diskspace? insufficent permissions?) which could leave you with an incomplete/invalid file. Reducing the 'critical' operation to a rename drastically reduces the chances of something going wrong.

  • Comment on Re^3: File::Path problem (will not create file if directory with same name exists)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-23 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found