At 8:39 am +0200 04.07.97, Alex Satrapa wrote: >Is there "The Right Way" to enter debugging comments into code? > >Here's how *I* do it... > [ ... snip ... ] A wise man once said "Never underestimate the value of 'print' statements for debugging." One refinement that I use is to hand the actual output off to a function, something like: sub debug { my($level,$message) = @_; print STDERR "DEBUG: $message\n" if ($DEBUG >= $level); } which can then be invoked by something like: &debug(2,"Oh no! We lost horribly!"); The advantage of doing it this way is that if you suddenly decide that you want to write your debugging output somewhere else or customize the output format, you can hack a single function rather than changing every single invocation in the entire program. It also makes for relatively clean and intelligible code. The actual amount of debugging information you see is controlled by the global $DEBUG variable, and each invocation of 'debug' specifies exactly how urgent the message in question is, so you can tailor the output to taste. There's probably an overhead involved in the function call (as opposed to inlining the print statement directly) but unless you're hitting it repeatedly in a tight loop, it's probably not important. I even leave this stuff in 'production code', on the grounds that you never get *all* the bugs out, and some day you may be glad of the ability to switch debugging back on by editing a single line in a configuration file. That's my take on it, but I'm a mere mortal in the world of Perl programming and, given that There's More Than One Way To Do It (tm), I await with interest to see what the Perl Gods recommend. A -- angus@pobox.com http://pobox.com/~angus/ "I know enough of the jargon to give me an "Rhapsody in Black" excuse for anything I want to do." [Grainger] Brian Stableford ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch