http://qs1969.pair.com?node_id=103526


in reply to Re: Re (tilly) 1: Tie & Destroy, OOP
in thread Tie & Destroy, OOP

Lexical or not, the question is whether the data is garbage collected before the end of the program. If it is done before then you get reliable destruction mechanics that we all know and love. If it is done in the final global destruction, data is terminated with prejudice at random.

BTW another solution that comes to mind is to use a flyweight pattern for your objects. That puts all of your current objects into a convenient hash that you can iterate through in an END block to do cleanup. Doing things that way gives you 2 wins. Better encapsulation, and it solves the global destruction problem in a way that is more likely to work across versions of Perl.