The Perl debuger is a wonderful tool. By setting its warnlevel or dielevel 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 ./.perldb or ~/.perldb file) allows you to set breakpoints (after printing the warn/dielevel stack traces, if any) on these events. Just type sow to stop on warn, or sod to stop on die.
update: made it pass args to oldWarn/oldDie
# 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 }/';
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|