The IPC::Run docs say this:

run() and finish() return TRUE when all subcommands exit with a 0 result code. ... All routines raise exceptions (via die()) when error conditions are recognized. A non-zero command result is not treated as an error condition, since some commands are tests whose results are reported in their exit codes.

Which tells me that the only thing you need to check is $?, and maybe ${^CHILD_ERROR_NATIVE} if you need to, or use the IPC::Run methods ->result or ->full_result. Since none of harness(), start(), run(), or finish() are documented to set any of $!, $^E, or $@ then checking them is likely to give you false positives - as other monks have said, a successful function call does not clear any of these variables, so the content of those variables may refer to some other operation preformed previously in the script (the exception being $? <update> by which I mean it gets set to zero after a successful system or equivalent, where the external command also returns an exit code of zero to indicate success. </update>). As a general rule, the Error Variables should only be considered to be valid immediately after the failed function call that is documented to set them - note how one writes open(...) or die "Error: $!", i.e. $! is only valid when open returns false. Note how the value of $! is useless after the second (successful) open:

use warnings; use strict; open my $fh1, '<', '/thisfiledoesntexist'; warn $!; open my $fh2, '<', '/etc/passwd'; warn $!; my @lines = <$fh2>; print "Read ",0+@lines," lines\n"; __END__ No such file or directory at - line 3. Inappropriate ioctl for device at - line 4. Read 45 lines

In reply to Re: error variables after IPC::Run by haukex
in thread error variables after IPC::Run by CarolinaPerler

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.