Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Conflicting usage recommendations: File::Temp and File::Copy

by barbie (Deacon)
on Sep 19, 2003 at 17:20 UTC ( [id://292717]=note: print w/replies, xml ) Need Help??


in reply to Conflicting usage recommendations: File::Temp and File::Copy

I'm assuming that the Java process is writing to the file you want to copy from. In this instance, how you access File::Temp is largely down to your preference, as only your process is using it and the file should have be created with a unique inode.

However, the File::Copy process is likely to get clobbered at some point, unless the Java does an atomic update. The Perl example is IO::AtomicFile. If an atomic update is used, then using filehandles will ensure you have a complete file. If this Java process doesn't use a atomic update method, then it's possible you will copy an incomplete or even corrupt file.

As others have mentioned, the context of how you use these modules, dictates whether the lines you quoted conflict. In this instance it may be safer to read from a filename and write to a filehandle. YMMV.

--
Barbie | Birmingham Perl Mongers | http://birmingham.pm.org/

  • Comment on Re: Conflicting usage recommendations: File::Temp and File::Copy

Replies are listed 'Best First'.
Re: Re: Conflicting usage recommendations: File::Temp and File::Copy
by kilinrax (Deacon) on Sep 19, 2003 at 17:37 UTC
    The code in question does check that the file isn't being accessed when it does the copy, and checks that the copy gets the whole file afterwards - so while I'd like to minimise the risk of such occurances, they're not disastrous unless they start occurring so often the script hits its retry limit and bails out.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-19 06:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found