in reply to How to explicitly destroy an object so that all other references to it would become false?
1)
Many thanks!
Many thanks!
2)
>do you have an example?
somewhere inside the scriptpackage XXX; my %already_created_objects; sub new { my ($class, $X) = @_; if (!$already_created_objects{$X}) { $already_created_objects{$X} = bless {somekey => $X} $class; } $already_created_objects{$X} }
... $obj = new XXX($some_var_which_can_repeat); ... if ($some_conditions) { some_superundef $obj } ...
Scalar::Util::weaken can do what I would like, but, as I've understood, it is required to mark as "weak" every reference to the object? Indirection layer seems more handy, may be...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to explicitly destroy an object so that all other references to it would become false? (just 1)
by tye (Sage) on Feb 21, 2008 at 16:05 UTC |
In Section
Seekers of Perl Wisdom