Morgon, interesting discussion you started.
I think the best you can do is to focus on "seen first, run last" and "end of scope".
Using those 2 points, I think the following is the closest to what you are asking for.
#!perl # Make this END block the first thing compiled to insure it # will be the last END block to run. END { # any special clean up goes here warn 'END - Bypassing final global Perl clean up'; # $? is the value passed to exit() unless modified # in another END block. POSIX::_exit($?); # WARNING - Any DESTRUCTions that could not be # completed before _exit() is called will NOT # be completed } # Create an extra layer of scope { use strict; use warnings; use Some::Module; my $s = Some::Module->new(); } # Close extra scope to trigger most of the DESTRUCTion exit(0); # Here, the various END blocks will run in reverse order # of being compiled, concluding with the END block at the # top of this file.
Disclaimer: Not tested. YMMV.
In reply to Re^3: is there a way to ensure some code is the last thing that is run?
by RonW
in thread is there a way to ensure some code is the last thing that is run?
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |