Sure it's easy enough to collect the return code (if any) from another failing program, after it was invoked from Perl..

What if an external program terminates with a single error code -- but for different causes, while additionally printing errors to standard output?
You didn't mention your platform, but at least on Unix and for some Windows programs, you could invoke your program from Perl along with some extra flags, redirecting any errors into a disk file, which your Perl script can read and analyze..
/my/prog 2> /private/debug-output.txt
To specifically answer your question 2: As others had said $? is what you need - but first find out what error codes your external program can return - that way you'll know what to match for in your Perl program.

At least there's one idea - but how you implement depends on a few variables - your program, what else it does, lots of things... if you post some code we'll get a better idea of your final intent..

If all you're looking to do is find out when your program died, use a wrapper script that tries to restart it and notify you ..

In reply to Re: Values returned to Perl by hsinclai
in thread Values returned to Perl by GraemeByers

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.