ddebrito has asked for the wisdom of the Perl Monks concerning the following question:

Does the perl debugger produce a signal when you quit it? Background: It would be nice to trap it and do some clean up because the DESTROY methods in my objects don't get processed when I quit in the debugger. Thanks.

Replies are listed 'Best First'.
Re: Debugger quit signal?
by cmeyer (Pilgrim) on Aug 30, 2007 at 21:10 UTC

    Perhaps you should post some example code that shows your problem. I coded up a simple test that shows DESTROY() being called, as I'd expect.

    # debug_test_DESTROY.pl package Foo; my $i; sub new { return bless [++$i] } sub DESTROY { warn "destroying object <$_[0][0]>\n"; } package Main; $x = Foo->new; $y = Foo->new; print "hello";
    > perl -d debug_test_DESTROY.pl Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. Foo::(debug_test_DESTROY.pl:3): my $i; DB<1> n Main::(debug_test_DESTROY.pl:15): $x = Foo->new; DB<1> n Main::(debug_test_DESTROY.pl:16): $y = Foo->new; DB<1> n Main::(debug_test_DESTROY.pl:18): print "hello"; DB<1> q destroying object <1> ## <--- look, DESTROY() called for $x ## at debug_test_DESTROY.pl line 10 Foo::DESTROY('Foo=ARRAY(0x97acc6c)') called at debug_test_DEST +ROY.pl line 0 eval {...} called at debug_test_DESTROY.pl line 0 destroying object <2> ## DESTROY() called for $y ## at debug_test_DESTROY.pl line 10 Foo::DESTROY('Foo=ARRAY(0x97f1348)') called at debug_test_DEST +ROY.pl line 0 eval {...} called at debug_test_DESTROY.pl line 0

    -Colin.

    WHITEPAGES.COM | INC

      Colin, Thanks. A big DOH! on my part. DESTROY is running when I quit the debugger (just as you also demoed) I had been using the debugger flag ( $^P ) in my code to prevent DESTROY from cleaning up some temp files so I could do further evaluation of those temp files. Ergo when I saw lots of temp files laying about I thought DESTROY was not running. Mea Culpa.
Re: Debugger quit signal?
by bruceb3 (Pilgrim) on Aug 30, 2007 at 20:31 UTC
    I don't know about a quit signal, but it does run any END blocks that you have setup.