Perl Debugger Module – CGI Debug – Command Line Debugging
Here we will take a quick look at Perl Debugger. Familarity with using perl debugger is assumed.
Related Terms – Debugging Tools, Perl Debugger Breakpoint, Perl Debug Command Line, Perl Debug Module, Perl Cgi Debug
Before we even get to the debugger… Have you:
- Turned on warnings via use warnings or perl –w?
- Do you use strict wherever possible?
- Does your script pass syntax checking (perl –c)?
Example 1 – Hello World
#!/usr/bin/perl
$var1 = 'Hello, world!';
$var2 = "$varl\n";
print $var2;
When not to use the debugger
- Not every case needs the debugger
- The debugger would not have provided any significant help with the previous example wIt is important to use other tools to find problems
What to use?
- perl5db.pl – The command line debugger
- GUI debugger – ptkdb
- ActiveState – PDK, Komodo
Starting the Perl debugger
- Called by perl –d
- Can be command line option: perl –d myscript.pl w…or part of the shebang line: #!/usr/bin/perl -d
The Most Important Commands
- q – Quits the debugge
- h – Displays help
The Perl text debugger Other common commands:
v [line] – View around line (current line by default) x expr – Evaluates an expression (in list context) m expr – Shows methods that expr->can do s – Step into n – Step over c line – Set a "one time" breakpoint
Working with variables & symbols
- M shows currently loaded modules + versions
- S shows currently available subroutines
- X / V shows variables in [current] package
Looking around
- v – Shows a “block” of code, starting from current position wl – shows a single line of code, starting from current position wEither command takes an optional parameter of a line number
- w. resets the line position to the current line
Practical use
- Normal “command line” scripts
- CGI scripts via –debug pragma or command arguments
- mod_perl via Apache::DB
- Not helpful for XSUB debugging
Perl Debugger GUIs
- ptkdb
- IDEs
- ActiveState PDK
I’ve personally found the PDK to be very weak (while somewhat simpler to navigate, set breakpoints, etc)
Komodo Debugger
- ActiveState’s opensource-language IDE
- Costs $$$
- New version 3.0 just released with very complete GUI debug tools wIncludes supports for watches, conditional breakpoints, immediate pane, etc wIncludes support for simulating full CGI environment
Reference: www.beamartyr.net/jerusalem.pm/debugger/debugger.ppt
Related Posts:
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Leave a comment.