I usually set $debug at top of a perl program or if I am trying to make something useful, in a module which is included by several. ($debug=$GlobalConfig::debug)

if ($debug>3) {print "Program Name: Error. $!";} ##DEBUG

I use 0=normal, 1..5 for more and more detail up to full DBI negotiation, and unique negative number ranges for debugging special cases.

This plus the block commenting code above seems useful. The worst thing I've had is a client that actually sent me back modified code (stripped out all my debugging and copyright info, also renaming the files, since their server couldn't handle something they had requested) and I had to take Ediff to it. You'd think the perl interpreter would not spend much time on testing the predefined constant..

You can also print to STDERR which you should be able to catch live in another window by grep tail your.httpd.error.log otherwise you'll need to turn on/off httpd header print statements in your code to be able to catch early config errors. Maybe better to look at that log agent module or something spiffier for mod_perl segfault strangeness..

Best regards,

Matt


In reply to RE: Easy, elemental, but cool debug trick. by mattr
in thread Easy, elemental, but cool debug trick. by jjhorner

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.