Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Object Suicide

by ChemBoy (Priest)
on Jun 15, 2007 at 20:00 UTC ( #621511=note: print w/ replies, xml ) Need Help??


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


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://621511]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-08-23 15:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls