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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Conditional DESTROY
by Ralesk (Pilgrim) on Jun 10, 2013 at 09:57 UTC |