perldoc -f qx

Um, the OP was asking about capturing the exit status of a C program, which involves using the "system()" call (perldoc -f system) -- not "qx" (aka the backtick operator), which just captures the program's stdout. Also -- OOPS, sorry. I should have read the docs more carefully myself, to see that qx returns stdout and sets $? -- thanks, I'm glad I finally learned that. Anyway (end of update), the more direct reference for qx is "perldoc perlop" (which is where "perldoc -f qx" tells you to look).

Another reply below points to the usage of "system()", along with the "$?" variable -- though I prefer using a scalar that has a meaningful name, e.g.:

my $exit_stat = system( "some_shell_command ..." ); printf "Shell_command exit status was %d\n", $exit_stat/256; print "(which means it probably failed)\n" if $exit_stat != 0;
(closing remark to updates: my old habit of using "system()" to get the exit status, vs. using backticks to get stdout data, was simply a matter of being unaware of the $? variable, which is set in either case.)

In reply to Re: Re: getting the return value from a C program by graff
in thread getting the return value from a C program by podian

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.