Previous Page
Next Page

18.11. The Debugger

Learn at least a subset of the perl debugger.

Perl's integrated debugger makes it very easy to watch your program's internal state change as it executes. At the very least, you should be familiar with the basic features summarized in Table 18-1.

Table 18-1. Debugger basics

Debugging task

Debugger command

To run a program under the debugger

> perl

To set a breakpoint at the current line

DB<1> b

To set a breakpoint at line 42

DB<1> b 42

To continue executing until the next break-point is reached

DB<1> c

To continue executing until line 86

DB<1> c 86

To continue executing until subroutine foo is called

DB<1>c foo

To execute the next statement

DB<1> n

To step into any subroutine call that's part of the next statement

DB<1> s

To run until the current subroutine returns

DB<1> r

To examine the contents of a variable

DB<1> x $variable

To have the debugger watch a variable or expression, and inform you whenever it changes


DB<1> wexpr($ess)*$ion

To view where you are in the source code

DB<1> v

To view line 99 of the source code

DB<1> v 99

To get helpful hints on the many other features of the debugger

DB<1> |h h

The standard perldebug and perldebtut documentation provide much more detail on using the debugger. You can also download and print out a handy free summary of the most commonly used commands from

    Previous Page
    Next Page