While others have posted links to other code that achieves
physi's desired
result, there is something which I think needs to be addressed in your code. While it certainly works and allows for a range of exit result eventualities, it does raise the age-old ire of using temporary files on systems. That is, the use of tempoary files with either predictable or known file names can allow for the trapping and redirection of output code.
Issues pertaining to the use of temporary files have been covered in a number of threads both on Perl Monks and on news groups, including here and here. I would also recommend having a look at the POD documentation for the File::Temp module which discusses temporary file issues.
I just wish I had saved the thread from comp.lang.perl.moderated that dealt with this issue in detail. At the very least I hope I have got you thinking ...
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.