in reply to Re: Getting around $? setting in END blocks
in thread Getting around $? setting in END blocks

Can you say "DOH!"?

Of course the "last" END block has to be compiled before the use statements get processed -- it's end blocks in use-d items that are giving me the headache. So you need:

use vars qw($exitval); END {$? = $exitval} use LotsOStuff; use MoreStuff; use TheOtherGuy'sStuff; use StuffYouProbablyDontNeed; # your code here END {$exitval = $?}