in reply to Returned Code

Could you please add some <code> tags to make your script readable? For example,

<code>
script goes here
</code>

UPDATE: I think the reason you're getting the '256' return is because your system("a.exe"); line is returning an error, not the bit-shifted '3' you are expecting. And I think it's returning an error because system() can't find a.exe, because it's not in your path. Does the return change if you specify system("./a.exe"); , or otherwise explicitly add in the path to the exe?

I'm not on a Windows system, so I can't test your script any more directly.

Replies are listed 'Best First'.
Re^2: Returned Code
by ikegami (Patriarch) on Jun 15, 2008 at 17:09 UTC

    "." is always in the front of the PATH in Windows (implicitly), so if system("a.exe"); fails, so would system(".\a.exe");. (system("./a.exe"); just plain won't work.)

    But, that's a good thoery

    >perl -e"print system 'nonexistant'" 'nonexistant' is not recognized as an internal or external command, operable program or batch file. 256
Re^2: Returned Code
by cdarke (Prior) on Jun 16, 2008 at 09:49 UTC
    As others have said, the exit value is shifted within the $? variable. This is for historical reasons and compatibility with UNIX. 256 will be returned on an exit code of 1 (one). Incidently, this also means that Perl on Windows places an artificial limit of 0-255 on the exit code.

    The current directory is the second place searched for executables, the first being the directory from which the calling application was loaded.