>my $signal = $? & 0xff;
This is almost right. :) You need only 7 bits to get the signal number.
The eighth bit is on iff core was dumped:
$ ulimit -c unlimited
$ perl -E 'system("kill -11 \$\$"); say $? & 0xff, ", ", $? & 0x7f'
139, 11
--
Jakub Wilk