When you use exec() in Perl:
Note that
execwill not call yourENDblocks, nor will it invokeDESTROYmethods on your objects.
How do I force perl to call END blocks anyway? Can I do something like END(); exec($0) or whatever?
I really am trying to make the program end its current instance and start a brand new instance of itself, and am too lazy to do this correctly (using cron or putting the entire program in an infinite loop). However, my END subroutines cleanup temp files and other important things, so I need them to run between executions.
Unhelpful links to code:
https://github.com/barrycarter/bcapps/blob/master/bc-metar-db.pl
https://github.com/barrycarter/bcapps/blob/master/bc-voronoi-temperature.pl
https://github.com/barrycarter/bcapps/blob/master/bc-delaunay-temperature.pl
To answer the narrow question of how to invoke your
ENDblocks at arbitrary times, you can use theB::end_avmethod withB::SV::object_2svrefto get the code references to yourENDblocks.Output:
I would usually prefer something less magical, though. Why not a structure like
?