in reply to Easy, elemental, but cool debug trick.

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

  • Comment on RE: Easy, elemental, but cool debug trick.

Replies are listed 'Best First'.
RE: RE: Easy, elemental, but cool debug trick.
by mattr (Curate) on Jun 11, 2000 at 15:15 UTC
    Oh forgot to say that the same client was saved by my leaving the debugging statements intact, since after telling them to change $debug I was able to debug it remotely through my browser after they had installed it on their own server.