You could override the builtin exit function for your testing
D:\Perl\test>perl58
use subs 'exit';
sub exit{ print 'Exit override received:', @_; CORE::exit(@_); }
exit 123;
^Z
Exit override received:123
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller