Home arrow Perl Programming arrow Page 2 - Perl Debuggers in Detail

perl5db.pl - Perl

In this second part of a two-part series on debugging Perl, we will go beyond the author's favorite debugger and look at a number of alternative Perl debuggers. This article is excerpted from chapter four of the book Mastering Perl, written by Brian D Foy (O'Reilly; ISBN: 0596527241). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

  1. Perl Debuggers in Detail
  2. perl5db.pl
  3. Alternative Debuggers
  4. Devel::ebug
  5. Other Debuggers
  6. Summary
By: O'Reilly Media
Rating: starstarstarstarstar / 3
July 31, 2008

print this article



We introduced the standard Perl debugger in Intermediate Perl so we could examine complex data structures. Itís well documented in the perldebug, and Richard Foley devoted an entire book, Pro Perl Debugging (Apress), to it, so I will only cover enough of the basics here so I can move on to the fancier debuggers.

I invoke the Perl debugger with Perlís -d switch:

  perl -d add_number.pl 5 6

Perl compiles the program, but stops before running the statements, giving me a prompt. The debugger shows me the program name, line number, and the next statement it will execute:

  Loading DB routines from perl5db.pl version 1.25
  Editor support available.

  Enter h or `h h' for help, or `man perldebug' for more help.

  3:     my $n = shift @ARGV;

From there I can do the usual debugging things, such as single-stepping through code, setting breakpoints, and examining the program state.

I can also run the debugger on a program I specify on the command line with the -e. I still get the debugger prompt, but itís not very useful for debugging a program. Instead, I have access to the debugger prompt where I can try Perl statements:

  $ perl -d -e 0

  Loading DB routines from perl5db.pl version 1.25
  Editor support available.

  Enter h or `h h' for help, or `man perldebug' for more help.

  main::(-e:1): 0
    D<1> $n = 1 + 2;

    D<2> x $n
  0  3

We showed this debugger in Intermediate Perl, and itís well documented in perldebug and many other tutorials, so I wonít spend time on it here. Check the references in the last section in this chapter, ďFurther Reading ,Ē for sources of more information.

>>> More Perl Programming Articles          >>> More By O'Reilly Media

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates


Dev Shed Tutorial Topics: