Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Object Suicide

by ChemBoy (Priest)
on Jun 15, 2007 at 20:00 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-19 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found