in reply to Re: [OT?] Today's Debugging Story
in thread [OT?] Today's Debugging Story

Cheers chromatic, nice idea.

Update: I should probably point out that I usually set an environment variable for debugging so that I can do this in my programs:
my $debug = $ENV{DEBUG} || 0;
The purpose of my post was a more light-hearted reflection of my day (i.e a joke) rather than a serious debugging tip (hence the OT warning in the subject). Thanks for the TIMTOWTDI debugging suggestion though.

-- vek --

Replies are listed 'Best First'.
Re^3: [OT?] Today's Debugging Story
by Aristotle (Chancellor) on Nov 27, 2002 at 11:39 UTC
    Using a constant is better if you don't need to switch the value at runtime:
    $ perl -MO=Deparse,-x7 -le'use constant DEBUG => 0; print "test" if DE +BUG' sub DEBUG () { package constant; $scalar; } '???'; -e syntax OK
    In other words, by using constants all of the debugging code is entirely removed from "production run mode". It's advisable because you avoid both the cost at runtime and (more importantly) can more reliably make sure you don't rely on any debugging code side effects. ("What? I can't initialize variables in an assert()?" :^) )

    Makeshifts last the longest.