in reply to Tie & Destroy, OOP
If you get rid of your objects before global destruction time, you won't have these problems. One solution is just to make sure that the objects are in an inner lexical scope:
Another solution is to deliberately clear object references in an END block:{ my $global = ...; sub doSomething { $global->whatever() } }
use strict; $^W++; $|++; package A; sub new { my $self = bless {}, $_[0]; print "construct $self\n"; $self; } # Package destructor sub END { print "in global destruction\n"; } # Object destructor sub DESTROY { print "destroying $_[0]\n"; } package main; our $a = A->new(); END { $a = undef; }
|
---|
In Section
Seekers of Perl Wisdom