in reply to Is there a way to know why the DESTROY method was invoked?
Yes.
#! perl -slw use strict; use Carp qw[ cluck ]; my $x = 0; $SIG{ __DIE__ } = sub{ $x = 1 }; sub DESTROY{ cluck 'DESTROY called' . ($x ? ' after die':'') } { my $r=bless[]; } my $r = bless[]; die 'dying'; __END__ c:\test>junk79 DESTROY called at C:\test\junk79.pl line 9 main::DESTROY('main=ARRAY(0xacf98)') called at C:\test\junk79. +pl line 15 eval {...} called at C:\test\junk79.pl line 15 dying at C:\test\junk79.pl line 17. DESTROY called after die at C:\test\junk79.pl line 9 main::DESTROY('main=ARRAY(0x2e67e8)') called at C:\test\junk79 +.pl line 17 eval {...} called at C:\test\junk79.pl line 17
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a way to know why the DESTROY method was invoked?
by erabus (Sexton) on Feb 18, 2010 at 18:49 UTC |