title: Why does my Perl script return a zero return code when I explicitly call exit with a non-zero parameter?
body: <p>I have a Perl script which calls another script. The Perl script should be propagating the script's return code but seems to be returning zero to its caller (a Java application) desipte the explicit call to <code>exit $scriptReturnCode</code>.</p>
  
  <p>Code and output as follows (I realise that <code>&lt;=&gt;</code> could/should be <code>!=</code> but that's what I have):</p>
  
  <pre><code>print "INFO: Calling ${scriptDirectory}/${script} ${args}"
  $scriptReturnCode = system("${scriptDirectory}/${script} ${args}");
  
  if ( $scriptReturnCode &lt;=&gt; 0 ) {
          print "ERROR: The script returned $scriptReturnCode\n";
          exit $scriptReturnCode;
  } else {
          print "INFO: The script returned $scriptReturnCode.\n";
          exit 0;
  }
  </code></pre>
  
  <p>The output I have from my Java is:</p>
  
  <pre><code>20/04/2010 14:40:01 - INFO: Calling /path/to/script/script.ksh arg1 arg2 
  20/04/2010 14:40:01 - Could not find installer files &lt;= this is from the script.ksh    
  20/04/2010 14:40:01 - ERROR: The script returned 256
  20/04/2010 14:40:01 - Command Finished. Exit Code: 0 &lt;= this is the Java app.
  </code></pre>