in reply to break on warning in debugger

You can use some trickery and get the warning to kick the debugger into single-step mode:

use strict; use warnings; $SIG{__WARN__} = sub { $DB::single = 1 }; my $c = 3; my $d = 'foo'; my $e = $c + $d; print "$e\n";

This will stop the program after the warning that caused the error (the addition of $c and $d). It is a much more difficult proposition to stop the program before the warning. Then again, this is probably sufficient 99.99% percent of the time.

Note that you still have to run the program under the debugger: perl -d myprogram. The gain is that you just have to <r>un the program, and it will churn away until a warning is raised.

• another intruder with the mooring in the heart of the Perl

Replies are listed 'Best First'.
Re^2: break on warning in debugger (r<c)
by tye (Sage) on Sep 25, 2007 at 15:27 UTC
    The gain is that you just have to <r>un the program, and it will churn away until a warning is raised.

    The 'r' command in the debugger does "return from current subroutine" (which means run the code until just after the code decides to return from the current subroutine, in case some find the former wording a bit unclear like I do). It doesn't mean "run", though it has a similar effect in that specific context. A more appropriate command is 'c' for 'continue'.

    In the debugger, if you are curious what a command does, type "h r" or "h c" to get a short description of just the "r" or "c" commands, BTW.

    - tye