Wednesday, May 19, 2010

Perl - Debugging Scripts

Issue: Using perl script and you need help finding a problem.

Quick: Use the built in debugger tools

perl -w scriptName    This will give you warnings about the script if there are any.
perl -d scriptName     Will put you in debug mode
w                               Lists code.  another w lists the next lines of code and so on
.                                 Resets code listing to current execution point
s                                Steps through code
n                               Steps through code and treats subroutines as a single step
p $variableName      Prints value of the variable
x %data                   Prints array data
x \%data                  Prints better looking array contents
b 20                         Set breakpoint at 20
L                           List all break points
d or D                      Deletes breakpoints
c                              Continues to break point
c 12                        Continues to line 12

Some links to debugger tutorials
Short Tutorial
Longer Tutorial

No comments: