I just read through this post on Tilly's advice on using File::Temp and it looks like just the recommendation I need. Unfortunately, my company doesnt stock File::Temp as a module, and the systems group is somewhat reluctant to field module requests from one of the network guys.
I read through IO::File's description on CPAN and found the new_tmpfile however it left me somewhat confused. My goal is to write to a completely random file and then attach it to an outbound email using Mail::Sender. For example...

## create message with attachment $sender->MailFile({ to => "$username\@mycompany.inc", subject => "$subject", msg => "Attached is the info you need!", file => "$tmpfile", });

Try as I might using IO::File, attaching the tmp file is just not happening. Maybe I am trying to use the temporary file for purposes that it's really not meant for?

Perhaps its easier to state the reason I need the tmpfile. My script will parse several configuration files and return the information to user as a CSV file attached to an email. I'd like to write to a completely randomly named file so that a devious individual won't try any of the tricks of symlinking a known output file's name to some other file/area on the machine in the hopes of causing trouble. Make sense?

Any help is appreciated. Humbly -c

ps. thanks again ybiC for that original post. i find most of my answers simply by perusing your writeups...


In reply to Creating temporary files without File::Temp by c

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.