This is basically how I use IPC::Run::run and check for success and exit code:
...
eval {
IPC::Run::run \@cmd, '>>', $outfile, '2>&1';
};
if($@) {
# Could not run the program
$fail_to_run=$@;
$exitcode=undef;
} else {
$fail_to_run=undef;
$exitcode=$? >> 8;
}
This piece of code is supposed to run under Unix and Windows. You will notice that I'm throwing away the low byte of $?. My understanding is that this would be not equal to zero only if the command could not be run, in which case
run throws an exception anyway. On the cases I found so far, this seemed to be true: I never had a $? with low byte not zero. Can I rely on this, or do I have to evaluate
$? & 0xff as well? Is there anything else I'm missing?
--
Ronald Fischer <ynnor@mm.st>
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.