Ralesk has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks,
my Google-fu isn’t being too good to me today, so I might be asking something that’s been asked a million times before. Sorry about that.
I have an object, and for various reasons, I’d like to have a DESTROY sub sometimes, but sometimes not. This destructor kills some processes related to this object as a last-minute clean up, but in some situations this is something that wreaks havoc and hence the conditional. So I thought of passing another param to new() and if it’s set, I'd like to bail out from the DESTROY call (return if $self->{no_destroy}). But it turns out that this variable is no longer set by the time we arrive to the DESTROY sub.
Is there anything I could do?
UPDATE: It seems it was a typical brown paper bag-quality 8th layer error. See the reduced code example in response to Corion’s reply, it works just fine.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conditional DESTROY
by BrowserUk (Patriarch) on Jun 10, 2013 at 09:45 UTC | |
by Ralesk (Pilgrim) on Jun 10, 2013 at 09:57 UTC | |
|
Re: Conditional DESTROY
by Corion (Patriarch) on Jun 10, 2013 at 09:29 UTC | |
by Ralesk (Pilgrim) on Jun 10, 2013 at 09:39 UTC | |
by Corion (Patriarch) on Jun 10, 2013 at 10:43 UTC | |
by Ralesk (Pilgrim) on Jun 10, 2013 at 10:54 UTC | |
|
Re: Conditional DESTROY
by syphilis (Archbishop) on Jun 10, 2013 at 09:45 UTC | |
by Ralesk (Pilgrim) on Jun 10, 2013 at 09:53 UTC |