in reply to Catching an object going out of scope
my $TEMPID; my %TEMPS; package My::Class::Temps; sub lookup ($) { $TEMPS{+shift} } sub new { my $self = {}; $TEMPS{ self->{ID} = ++$TEMPID } = $self; $self; }
Now you can store $self->{ID} and use lookup() to find the corresponding object. Such storage of a unique ID doesn't increase reference counts, so it's rather like a weak reference, albeit not nearly as convenient.
-- Chip Salzenberg, Free-Floating Agent of Chaos
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Catching an object going out of scope
by Masem (Monsignor) on Nov 13, 2001 at 23:53 UTC |