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.