Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Object Suicide

by sfink (Deacon)
on Jun 16, 2007 at 20:42 UTC ( #621619=note: print w/ replies, xml ) Need Help??


in reply to Object Suicide

At the cost of making all of your references circular, you could store a reference to an object's list slot within the object itself:

foreach (@GLOBAL_OBJECT_LIST) { $_->{backref} = \$_; }
then to commit suicide you'd do:
undef ${ $_->{backref} };
The nasty part of that is that none of your objects will ever get destroyed automatically because of the circular references. You could make the backrefs weak to fix that, but assuming the list really is global, then it would be much simpler to commit suicide with:
@GLOBAL_OBJECT_LIST = grep { $_ != $self } @GLOBAL_OBJECT_LIST;


Comment on Re: Object Suicide
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://621619]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-07-10 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (198 votes), past polls