So here's my debugging tip of the day. When attempting to run a Perl program in debug on a Windows box via DOS, you're probably going to want to comment out any code that makes the DOS window vanish. It's a little difficult to debug code on the command line without a DOS window :-)

Laugh? I nearly shat myself. My co-workers seated in close proximity must have thought I'd lost my marbles.

Update: As I mentioned to chromatic below, this was meant to be a light hearted post rather than a serious debugging tip ;-)

-- vek --

Replies are listed 'Best First'.
Re: [OT?] Today's Debugging Story
by chromatic (Archbishop) on Nov 22, 2002 at 01:29 UTC

    Instead of commenting out code (you might forget to uncomment it), how about using a debugging constant?

    BEGIN { require constant; constant->import( DEBUGGING => $ENV{DEBUGGING} ); } hide_console() unless (DEBUGGING);
      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 --
        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.

      You can use constant DEBUG => $ENV{DEBUG}; actually.

      Makeshifts last the longest.