Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No, not really.</p> <p>Things you can do are:</p> <p>Sprinkle your code with debug code.</p> <pre><code>use constant DEBUG =&gt; 1; ...; debug_function($var) if DEBUG; </code></pre> <p>Once you unset the <code>DEBUG</code> constant for deployment, you won't have any extra runtime costs (the statements are optimized away), and you can re-activate them whenever neccessary.</p> <p>You can even say evil things like</p> <pre><code>BEGIN {require Data::Dumper if DEBUG} </code></pre> <p>to conditionally load debugging modules.</p> <p>If you want to override Core functions, why not add debug handlers? That's not evil patching, thats augmenting…</p> <pre><code>BEGIN { if (DEBUG) { my $oldfunction = \&amp;CORE::function; *CORE::function = sub { # add prototypes if you like them debug_handler(@_); &amp;$oldfunction; }; } } </code></pre> <p>Use this technique to log your calls to your database.</p> <p>You can re-open <code>STDERR</code> to some special file (or pipe, or terminal, or…)</p> <pre><code>BEGIN { if (DEBUG) { close STDERR or die "STDERR hates me and doesn't want to be closed."; open STDERR, '&gt;', "/path/to/my/error/log.file" or die "couldn't open error log"; } } </code></pre> <p>You can define your <code>DIE</code> and <code>WARN</code> handlers to do something <em>you</em> want:</p> <pre><code>$SIG{__WARN__} = sub { print MYERRORS "There was a warning: $!"; # do additional error handling unless you're paranoid } </code></pre> <p>The <code>warnings</code> pragma can help you to make important warnings fatal:</p> <pre><code>use warnings qw(FATAL importantWarning); </code></pre> <p>or to create your own warnings, just see the documentation</p> <p>And to get call stack traces, look into the numerous possibilities of the <code>caller</code> function. Essentially, you might want to build your personal interpretation of the <code>Carp</code> module as <code>CGI::Carp</code> may not meet your needs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload