in reply to Reading return value from C program

You might find this thread insightful.

As for !$?, $? is a Perl special variable for child error. So if your script forks a child process and there is an error, this will contain that error. ! is the not operator. I'm guessing you're seeing something like:

if ( !$? ){ # do the stuff you do after a forked process completes sucessfully }

But that would be much easier to read as:

use English qw(no_match_vars); if ( not $CHILD_ERROR ){ # do the stuff you do after a forked process completes sucessfully }

Updated comments to reflect meaning of $?

Replies are listed 'Best First'.
Re^2: Reading return value from C program
by ikegami (Patriarch) on Mar 15, 2007 at 18:00 UTC
    fork sets $!, not $?.
      agianni's code wouldn't make sense after a fork(), that's true. It would make sense after a waitpid. Maybe that was the tacit assumption. It would have been better made explicit.

      Anno

        Even after waitpid, $? doesn't indicate whether the child was launched successfully or not. $? indicates whether the child *ended* successfully.