Me bad. That should have been

use Devel::Peek; 1 if $?; # mg_get Dump($?);

But don't bother. The only way only what you said could happen is if system and $? are not returning the same thing like they are suppose to. I could ask you to show me a dump of both to confirm that or to show that what you said is wrong. Neither outcome would be productive.

Since there's no reason to check both, pick one. (See snippets below.) If you then have problems with it containing the wrong value, we'll investigate why it has the wrong value then, knowing what value is obtained and what the value should be.

system($cmd); if ($? == -1) { die("Can't execute command: $!\n"); } elsif ($? & 127) { die("Command died from signal ", ($? & 127), "\n"); } elsif ($? >> 8) { die("Command exited with error ", ($? >> 8), "\n"); }
or
my $rv = system($cmd); if ($rv == -1) { die("Can't execute command: $!\n"); } elsif ($rv & 127) { die("Command died from signal ", ($rv & 127), "\n"); } elsif ($rv >> 8) { die("Command exited with error ", ($rv >> 8), "\n"); }

By the way, make sure you aren't using system and fork in the same program.


In reply to Re^3: How to get output from a forked cmd prompt? by ikegami
in thread How to get output from a spawned cmd prompt? by Xhings

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.