in reply to Need to capture return code

With $?, you have to be careful that, its value is not exactly what returned from sub process, but $? >> 8 is.

Try this out with those two pieces of code:

system("perl -w c.pl"); print $? >> 8, "\n"; #this gives you 10 print $?; #this gives you 2560

c.pl:

exit 10;

Replies are listed 'Best First'.
Re^2: Need to capture return code
by James_Marcinek (Initiate) on Oct 11, 2004 at 19:59 UTC
    That statement looks like a redirect into a file (in Unix and NT)?

    print $? >> 8, "\n"; #this gives you 10 print $?; #this gives you 2560

    OOPS, I meant ->I'm not familiar with this obviously ($?>>8)
    Okay I did a search and found it shifts it over 8 digits