in reply to Re: exec with cleanup
in thread exec with cleanup

Yeah, this is the solution I was going to recommend, but you got to it first. :)

The perlmod page clearly says that the first END that perl encounters is the last one that gets run, so maybe something like this would work for you:

# very very top of your first file END { if (@::final_exec) { exec {$::final_exec[0]} @::final_exec; } } # later that same day... @::final_exec = ($^X, 'scriptname.pl', @args);