http://qs321.pair.com?node_id=88123

HamNRye has asked for the wisdom of the Perl Monks concerning the following question:

This is going to sound like a total newbie question, but I've been using scripting langs for a while now, and I've never had, had to use, needed, configured, or wanted a debugger. I've been playing with Komodo a bit, and about a week of monkeying around with it has revealed that I have no frakkin' clue how to use a debugger.

I followed their help files and gave it a whirl, but it was too jargonized for my comprehension. (Kind of like when I started Perl, list context and scalar context become harder to understand becuz WTF is a scalar anyway?)

Does anyone know of a good overview of debugger concepts or better yet, a human readable tutorial for the perl debugger. (Better still, both) Thanks for the info....

DISCLAIMER: I never claimed to be a perl guru baby, you'll just have to take me as I am.

Replies are listed 'Best First'.
Re: Debugger Tutorials
by bikeNomad (Priest) on Jun 13, 2001 at 21:03 UTC
Re: Debugger Tutorials
by VSarkiss (Monsignor) on Jun 14, 2001 at 00:01 UTC
    I echo bikeNomad's recommendation of the Linux Journal article (I don't think the Monastery's article is as good. YMMV).

    What really made me start making better use of the debugger is Effective Perl Programming by Hall and Schwartz. One of their recommendations I liked best was to use the debugger as an interactive Perl environment. That is, just type: perl -d -e 0 and any Perl you enter at the prompt will be executed. Combine this with the debugger's x command, and you have a nice way of, for example, analyzing data structures.

    Don't be overwhelmed by the ton of commands that appear in the help. I hardly ever use more than these:

    • x: nicely formatted display of any variable: scalar, array, or hash
    • p: print the argument, like the built-in
    • w: show a 10-line window around the current line.
    • s and n: step the program, optionally stepping over an entire sub
    • b: break execution at line
    • c: continue executing until reaching line
    • q: quit (kinda necessary, that one)
    As others have pointed out in this thread, it won't help if your program won't compile. But that's true of debuggers for any compiled language.

    HTH

Re: Debugger Tutorials
by nysus (Parson) on Jun 13, 2001 at 21:15 UTC
    Basic debugger concept #1: the built in Perl debugger referenced above will not work unless your program compiles. So if you have major flaws in your code, the built-in Perl debugger is useless. So as a first step, be sure you:
    use strict;
    use diagnostics;
    and to call Perl using the '-w' (warnings) switch.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot";
    $nysus = $PM . $MCF;

      This is not a problem with programs compiling, I just want to know how to debug a program without seeding it with print statements. I'm assuming this is the point of a debugger.

      I have been writing Perl for 5 years now, but I have always debugged with the old print "Count is" $count ; and the like. As my projects get more and more complex, this becomes more and more tiresome.

Re: Debugger Tutorials
by pmas (Hermit) on Jun 13, 2001 at 22:08 UTC
    I never used it myself yet, but title sound very intriguing

    Jürgen Güntherodt anounced Open Perl IDE, free lookalike of VisualPerl, with features:
    -Perl Syntax Coloring
    -Visual Debugging
    -Integrated Help System
    -Customizable Environment

    Jürgen invited to look at http://open-perl-ide.sourceforge.net

    Try take a look, and then tell us...:)

    pmas

    To make errors is human. But to make million errors per second, you need a computer.

Re: Debugger Tutorials
by frag (Hermit) on Jun 14, 2001 at 01:43 UTC
Re: Debugger Tutorials
by schumi (Hermit) on Jun 14, 2001 at 00:28 UTC
    I second the article that both bikeNomad and VSarkiss mention. However, if you want something more concise, try this brief tutorial about using the Perl debugger. It deals with some of the most common problems in pretty "human readable" format, it seems to me.

    -- cs

Re: Debugger Tutorials
by princepawn (Parson) on Jun 13, 2001 at 23:01 UTC