No such thing as a small change | |
PerlMonks |
Re^4: is there a way to ensure some code is the last thing that is run? (SUPEREND)by LanX (Saint) |
on Feb 03, 2017 at 13:13 UTC ( [id://1180959]=note: print w/replies, xml ) | Need Help?? |
The following will demonstrate an approach to define a &SUPEREND::DESTROY which is run after all other global DESTROY()s happend.
Please note, that this can be extended to be a generic solution, because SUPEREND could parse all packages available and monkeypatch all DESTROYs there (if existent) Since $persist is referenced it's DESTROY will be run last. For syntactic sugar one could also make SUPEREND export a function SUPEREND(&) accepting a codeblock which is run by the DESTROY of $persist.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|