I am having a problem with an OOP implementation, where it appears that Perl
is garbage collecting even though there are outstanding references. The
scoop:
I have a main script (package main) that instantiates a Logger (no relation
to Unix command), an Error, and a Result object, in that order. The Error
object uses the Logger and Result object for certain functions. The logger
object is passed to the error object constructor which adds it to its hash:
sub new {
my($class, $log_obj) = @_;
my $obj = { log => $log_obj ...etc... };
return bless $obj;
}
The Result object is added afterward using an object method. The problem I
am having is that when the Error object's DESTROY method is called, the log
object element ($self->{'log'}) is undefined. I thought it shouldn't be
destroyed, since there would be an outstanding reference. Has anyone come
across this and can explain why and some workarounds? (I have discovered
that the order in which objects are constructed is irrelevant to the order
they are destroyed).
-K
"Do not meddle in the affairs of dragons, because you are crunchy and taste
good with ketchup."