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/


In reply to Re: Conflicting usage recommendations: File::Temp and File::Copy by barbie
in thread Conflicting usage recommendations: File::Temp and File::Copy by kilinrax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.