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


in reply to Conditional DESTROY

You could try storing the flag outside of the object itself:

package whatever; my %customDestroy; sub new { my( $class, $flag, ... ) = @_; my $self = {}; ... $customDestroy{ $self } = 1 if $flag; return bless $self, $slass; } ... sub DESTROY { my $self = shift; if( $customDestroy{ $self } ) { ## special behaviour } else { ## normal behaviour } }

I think package lexicals should persist long enough to outlive instances, though I haven't tested the hypothesis.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.