Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I think you should take a closer look as to how these modules work. I haven't worked with File::Temp in a while, but, if I remember correctly, it's purpose was to create a file with a random or semi-random name that would go away the second the program is completed. The module considers the filename to be mostly irrelevant because it doesn't know the filename when the program starts. File::Copy, however, works mainly under the assumption that you know what the filename is.

The warning in File::Temp is mainly for security purposes, so a hacker can't be just watching for the existance of a particular file, and attack. For example, if you had a Perl program to do a mass insert into the passwd file on UNIX, it wouldn't be to good to have a fixed file name that a hacker could intercept and add to during an update. It's also to prevent race conditions where you would have multiple process potentially creating a similar temp files at the same time. I'm not a security expert, but if you have one singe-threaded process copying a single file to a temporary location, I cannot see where using the filename from File::Temp would be a problem.


In reply to Re: Conflicting usage recommendations: File::Temp and File::Copy by Steve_p
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-29 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found