In Perl, the debugger is not a separate program as it usually is in the typical compiled environment. Instead, the -d flag tells the compiler to insert source information into the parse trees it's about to hand off to the interpreter. That means your code must first compile correctly for the debugger to work on it.
If you invoke Perl with the -d switch, your script runs under the Perl source debugger. This works like an interactive Perl environment, prompting for debugger commands that let you examine source code, set breakpoints, get stack backtraces, change the values of variables, etc.
b-command is used to set a breakpoint in a program. Whenever a specified line is about to be executed, this command tells the debugger to halt the program. Note : There can be any number of breakpoints in a program.
Available tools for debugging
There are several tools available in Perl for debugging and similar tasks.
Built-in command line debugger.
perl -d yourcode.pl
Devel::ptkdb
Perl/Tk based graphical debugger by Andrew E. Page.
Regex Coach
This a free tool running both on Linux and Windows written in Lisp. Source code is not available.
Rx: A Regex Debugger for Perl
The Perl Regex debugger and an article about it written by Mark Jason Dominus.
A GUI for the Perl Debugger
There are lots of things out there to help you:
*
when the code throws a warningI like Devel::Trace. Basically it gives you an execution dump, showing you the code paths.
On another side, test-driven development is all the rage now, so you could also be interested in profiling tools like Devel::NYTProf for highly advanced testing. See this Tim Bunce's blog post for an interesting overview.
I use ActiveState Komodo for step-by-step debugging.
Eclipse has a step by step debugger for its EPIC plugin.
Personally I prefer the ActiveState version. It just seems more solid and stable, but it does cost (and work is paying for me). If it was my money then I would use Eclipse and EPIC as these are free.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With