Perl's debugger is a command line debugger, so while it's not
pretty, with buttons and little red lines for your breakpoints,
it can be pretty durn effective once you get used to it. This
isn't so much of a tutorial as a brief overview of the most common commands.
bash$ perl -d myscript.pl
This will put you in the command
line mode. It looks like:
main::(perl/test.pl:5): print "Just another perl monk\n";
Dissecting it, we have this information:
Module::(sub module)::function(physical file location:line number): current line of code;
now you can type in whatever you want to make your program proceed.
Know your command set!
Here's a few of the more often-used commands:
n -- next. Proceed to the next command
s -- step (in). If you are in a function call, proceed to that function.
x -- eXecute. Although it's more like eval. This lets you monitor variables,
or execute arbitrary code. "x $FOO" will print out the value of
$FOO, etc. It will automatically expand references, which is nice if you are using complex data structures.
b LINE -- Set a breakpoint on the target line. This way when you use "c", it will stop at the breakpoint
c -- continue running until breakpoint.
T -- print the call stack of functions
<enter> -- repeats the last command. Useful when preceeded by "n" or "s".
h -- help. Prints out a much more comprehensive command list than this...
q -- quit.
What? More functionality?
Of course there's a hell of a lot more functionality! Check out the perldebug man page...
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.