in reply to Re^2: I usually debug via...
in thread I usually debug via...

comment them out when I don't need them

Have you considered trying something like

warn "The code is running in debug" if $::debugging;

This way you can just say $debugging = 1; instead of changing many lines of code. vim is a great tool, but it isn't a debugger. For debugging, you need emacs. :-)

Update: You could even have $::debugging set by command-line switches, or an %ENV variable or a CGI parameter. Then you would not need to change any of the code to get some debugging info. This is great if something prevents you from touching the code, for example if it is running on a production web server.

Replies are listed 'Best First'.
Re^4: I usually debug via...
by ff (Hermit) on Feb 15, 2005 at 22:22 UTC
    Generally a good approach, except that my programs are large and that could turn on hundreds of warnings. For me, I generally just need to turn on a few warnings at any given time and it's no big deal to hop around to those four or five that I've unmasked to comment them back up.

      My code is usually littered with stuff like print "Foo: ".Dumper(\$foo) if $debug>7;

      Often I write those in not knowing if I'll ever want that level of verbosity; usually I never have to crank $debug higher than 2 or 3. (1 just prints progress info usually, depending on what the app is; 2 gives more detail, and so on. 0 only prints actual errors, and undef suppresses non-fatal errors. Anything past 5 is dumping lots of big data structures.) Occasionally I do end up cranking it way up, though, and adding in extra print statements like the above, that I didn't originally anticipate needing.

Re^4: I usually debug via...
by JediWizard (Deacon) on Feb 16, 2005 at 15:58 UTC

    When I write CGI scripts, I like to have a &printError(); routine. Then all my debug statments call &printError("Message", $debug_level);. Based either on a config file, or and environment variable, &printError(); can decide whether or not $debug_level is high enough to send the message out to STDERR.

    May the Force be with you