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.
|