in reply to How to get system -function negative return value?

System function return 8 bit values. Depending whether you treat the values as signed or unsigned, they are in the range -128 .. 127, or 0 .. 255. When doing system from Perl, the return value of the called program is the second least significant byte of the return value of system (and also available in $?). Since only the two least significant bytes are used (the least significant byte contains information about signals and core dumps), shifting 8 bits will give you the return value - unsigned.

To get the signed value, do something like:

my $ret_val = unpack c => pack C => ($? >> 8);

Abigail