in reply to Reading return value from C program

How does your C program return an integer? Does it print it to the screen? Return it as its exit value? Something else? The answer to your question depends entirely on that.

As a Perl expression, !$? is the logical negation of the value of the system variable $?. If you are in fact after the exit value of a program, this (the variable, not its negation) would be the place to look, but read about $? in perldoc perlvar.

Anno

Replies are listed 'Best First'.
Re^2: Reading return value from C program
by Anonymous Monk on Mar 25, 2007 at 07:06 UTC
    I got my answer. We can use "$?>>8" to get the read the return value, however it's returning only positive value.Any one knows how to read the negative values as well
      You can interpret the byte as a signed byte:
      my $exit_code = $? >> 8; $exit_code -= 256 if $exit_code > 127;
      But that won't tell you whether the program has specified its exit code as a negative number. All you get is the least significant eight bytes of the value.

      Anno