in reply to Subroutine to indicate error condition

moritz is right, of course, that a module or subroutine should not use exit (unless specifically designed for that purpose), maybe you are stuck with some code that someone else wrote? You can detect an exit by using an END block, for example:
# gash.pm package gash; use warnings; use strict; sub gashsub { print "In gashsub\n"; exit 1; } END { print __PACKAGE__." is exiting $?\n"; } 1; # main.pl #!/usr/bin/perl use warnings; use strict ; use gash; gash::gashsub(); END { print __PACKAGE__." is exiting $?\n"; }
Produces the output:
In gashsub main is exiting 1 gash is exiting 1
The exit value is in $?.

Subroutines should ideally use die, which can then be trapped using eval.