in reply to Object Suicide
What you're trying to do here is definitely possible, though I'm not sure it's advisable. The key is that you can't use the standard my $self = shift; boilerplate in that method, because that makes a copy of the caller's reference, rather than operating on it directly (this is usually a good thing). Rather, it would need to look something like the below:
sub method_which_may_suicide { my ($self,@arglist) = @_; if (_should_suicide(@arglist) ) { undef $_[0]; } }
Note that this will only destroy the reference in the immediate calling code—if you call this from another method that uses the my $self = shift; trick, it will not propagate the change to whoever called that method. And again, <symbolic hand-washing>I'm not advising you to do this, but it's there if you want it</symbolic hand-washing>. :-)
If God had meant us to fly, he would *never* have given us the railroads.
--Michael Flanders
|
---|
In Section
Seekers of Perl Wisdom