http://www.perlmonks.org?node_id=621619


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;