in reply to debugging trick of the week: fatal warnings

I used to do this in the pre-5.6 days with a __WARN__ handler:

$SIG{'__WARN__'} = sub { die $_[0]};
Or something along those lines. I used it when I wanted find the cause of warnings in a very long-running script. I'd start the script with -d, and when it hit a warning it would pop me into the debugger and I could check the current value of all variables, step forward, etc.

Replies are listed 'Best First'.
Re: Re: debugging trick of the week: fatal warnings
by stephen (Priest) on Apr 26, 2002 at 03:40 UTC
    If you want warnings to stop your debugger if it's running, but not to actually die, this seems to work:
    $SIG{'__WARN__'} = sub { warn $_[0]; $DB::single = $DB::single; $DB::s +ingle = 1; };
    It automatically slams the debugger into single-step mode every time there's a warning. (The $DB::single = $DB::single is just to keep -w happy.)