in reply to Catching an object going out of scope

I have an object, "My::Class", that creates objects of a second type "My::Class::Temps"
Ok, My::Class is a factory class for My::Class::Temps

Is there a way to capture the point where an object is going out of scope but not necessarily being deleted, such that special actions can be taken?
DESTROY {    } is the answer to this question in isolation but in order to automate destruction of this object automatically, you simply need to weaken the reference count. I thought gbarr had written something to do this but CPAN shows two others : Devel::WeakRef and WeakRef

Replies are listed 'Best First'.
Re: Re: Catching an object going out of scope
by gildir (Pilgrim) on Nov 13, 2001 at 13:50 UTC
    Just a remark to add.
    Weak references are available only in perl 5.6 or higher (production branch). There is no support of weakref in widespread 5.005_3 version of perl.

    In perl 5.005_3 you can't do just nothing about circular refs. The only thing you can do is give user a chance to release reference cycle manualy (by calling $o->release method for example).