Perl Debugger
perldoc.perl.org
What it is
Perl Debugger is an interactive debugger included with Perl, not a separate program. Running Perl with the `-d` flag loads the debugger and adds source information, allowing users to inspect code, set breakpoints, view stack backtraces, and change variable values. The program must compile correctly before debugging.
Debugger commands support stepping into subroutine calls, stepping over them, and tracing execution. Conditional breakpoints and watches on global expressions can pause a run when specified conditions or changes occur. The `x` command can pretty-print nested data; displaying lexical variables requires PadWalker version 0.08 or higher. Options can be set interactively, through `PERLDB_OPTS`, or in `.perldb` files. Documentation also describes a GUI option through Devel::ptkdb. The debugger does not provide stack-frame information for functions not compiled by Perl, such as C or C++ extension functions, and compile-time executable statements are not stopped, though some can be traced with AutoTrace. Perl is listed for Linux, macOS, and Windows, and the debugger is free.
Spec sheet
- Purpose
- The Perl source debugger runs scripts interactively and lets users inspect source, set breakpoints, get stack backtraces, and change variable values.Read 7 Oct 2026 · perldoc.perl.org
- Support
- The download page points learners to learn.perl.org and the Perl Community for help.Read 7 Oct 2026 · perl.org
- Breakpoints and watches
- Users can set conditional breakpoints and watch global expressions for changes.Read 7 Oct 2026 · perldoc.perl.org
- Built into Perl
- The debugger is not a separate program; Perl’s `-d` flag makes the compiler insert source information and preload the debugger library.Read 7 Oct 2026 · perldoc.perl.org
- Compile requirement
- The code must compile correctly for the debugger to work on it.Read 7 Oct 2026 · perldoc.perl.org
- Compile-time limit
- Compile-time executable statements such as BEGIN, UNITCHECK, CHECK, and use statements are not stopped by the debugger, though some compile-time code can be traced with AutoTrace.Read 7 Oct 2026 · perldoc.perl.org
- Compile-time limitation
- Compile-time executable statements such as `BEGIN`, `UNITCHECK`, `CHECK`, and `use` are not stopped by the debugger, though some can be traced with `AutoTrace`.Read 7 Oct 2026 · perldoc.perl.org
- Customizable
- Debugger options can be set interactively, through the PERLDB_OPTS environment variable, or in customization files.Read 7 Oct 2026 · perldoc.perl.org
- Customization
- Options can be set interactively, through `PERLDB_OPTS`, or in `.perldb` customization files.Read 7 Oct 2026 · perldoc.perl.org
- Editor connections
- The LineInfo option provides a mechanism to interact with client editors or visual debuggers, with vi, emacs, and ddd given as examples.Read 7 Oct 2026 · perldoc.perl.org
- GUI option
- The documentation describes debugging a program through the Devel::ptkdb GUI using `perl -d:ptkdb`.Read 7 Oct 2026 · perldoc.perl.org
- Inspect and control execution
- Debugger commands can examine source code, set breakpoints, show stack backtraces, and change variable values.Read 7 Oct 2026 · perldoc.perl.org
- Inspect values
- The x command evaluates an expression and pretty-prints nested data structures recursively.Read 7 Oct 2026 · perldoc.perl.org
- Interactive evaluation
- Commands the debugger does not recognize are evaluated as Perl code in the current package.Read 7 Oct 2026 · perldoc.perl.org
- Native extension limitation
- The debugger cannot provide stack-frame information or debug functions that were not compiled by Perl, such as C or C++ extension functions.Read 7 Oct 2026 · perldoc.perl.org
- Notable limit
- The debugger cannot provide stack-frame information for functions not compiled by Perl, such as those from C or C++ extensions.Read 7 Oct 2026 · perldoc.perl.org
- Optional dependencies
- Lexical variable inspection requires PadWalker, and full command-line editing requires Term::ReadKey and a Term::ReadLine module.Read 7 Oct 2026 · perldoc.perl.org
- Platform availability
- The Perl download page lists Perl as included on Unix/Linux and macOS, and provides a Windows option through Strawberry Perl.Read 7 Oct 2026 · perl.org
- Project licensing
- Perl is open source and is licensed under either the Artistic License or the GNU General Public License.Read 7 Oct 2026 · perl.org
- Security detail
- The documentation says .perldb may contain arbitrary commands and must be owned by the superuser or current user and writable only by its owner.Read 7 Oct 2026 · perldoc.perl.org
- Step through code
- The s command steps into subroutine calls, while n executes over them to the next statement.Read 7 Oct 2026 · perldoc.perl.org
- Stepping and tracing
- Commands support single stepping, stepping over subroutine calls, and tracing execution.Read 7 Oct 2026 · perldoc.perl.org
- Threaded debugging
- The `-dt` invocation debugs a threaded program and is marked experimental.Read 7 Oct 2026 · perldoc.perl.org
- Variable inspection
- The debugger can pretty-print nested data and display package variables; lexical-variable display requires PadWalker version 0.08 or higher.Read 7 Oct 2026 · perldoc.perl.org
- Warning switch limitation
- The debugger does not currently work with Perl’s `-W` command-line switch.Read 7 Oct 2026 · perldoc.perl.org
- Watch expressions
- A global watch expression stops execution and displays old and new values when a watched global changes.Read 7 Oct 2026 · perldoc.perl.org
Plans and prices
Strong points and limits
Strong points
- Included with Perl and free.
- Supports conditional breakpoints and global watches.
- Can pretty-print nested data structures.
- Options can be customized in several ways.
Limits
- The program must compile correctly first.
- Lexical-variable display requires PadWalker version 0.08 or higher.
- No stack-frame information for C or C++ extension functions.
- Compile-time executable statements are not stopped.
Who it suits
It suits Perl developers who need interactive stepping, conditional breakpoints, watches, and variable inspection. Lexical-variable inspection requires PadWalker, and debugging is limited for code not compiled by Perl.
Verdict
Perl Debugger provides core interactive inspection and control for Perl programs without a separate purchase. Its compile-time and native-extension limits matter when debugging beyond Perl-compiled code.
Where Specifiction places it
- Debuggers#5 of 278.5