CUFP
bikeNomad
snippet
<div class="Description">The Perl debuger is a wonderful tool. By setting its <b>warnlevel</b> or <b>dielevel</b> you can get it to print out a stack trace on a warn or a die. But what if you want to breakpoint on those events? This snippet (when put into a <b>./.perldb</b> or <b>~/.perldb</b> file) allows you to set breakpoints (after printing the warn/dielevel stack traces, if any) on these events. Just type <b>sow</b> to stop on warn, or <b>sod</b> to stop on die.<p>
<b>update:</b> made it pass args to oldWarn/oldDie</div>
<CODE>
# Stop on warn (sow)
$DB::oldWarn = $SIG{__WARN__};
$DB::alias{sow} = 's/^sow/\$SIG{__WARN__} = sub { \$DB::oldWarn->(@_) if (\$DB::oldWarn); \$DB::single = 1 }/';
# Stop on die (sod)
$DB::oldDie = $SIG{__DIE__};
$DB::alias{sod} = 's/^sod/\$SIG{__DIE__} = sub { \$DB::oldDie->(@_) if (\$DB::oldDie); \$DB::single = 1 }/';
</CODE>