in reply to Storing object references internally
Actually you are not storing the object itself somewhere in the class, because a hash can only use strings as hash keys. So setting
is actually first stringifying the object — which works very well as long as you haven't overloaded the '""' operator — but it is no longer an actual reference. It's a different thing if you store the object somewhere in the hash value.$objects{$obj} = $info_about_me;
If you want to purge this info from the hash when the object is destroyed, you can do that in the DESTROY method. That's what the Inside Out Objects do.
sub DESTROY { my $self = shift; delete $objects{$self}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Storing object references internally
by Forsaken (Friar) on Apr 23, 2005 at 09:18 UTC | |
by bart (Canon) on Apr 23, 2005 at 09:28 UTC |