Perl Debugger
perldoc.perl.org
- Free plan
- Windows
- macOS
- Linux
What Perl Debugger is
Perl Debugger is an interactive debugging tool included with Perl rather than 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. Commands support stepping into subroutine calls, stepping over them, and tracing execution. Conditional breakpoints and watches on global expressions can help follow changes during a run, while the `x` command can pretty-print nested data. Displaying lexical variables requires PadWalker version 0.08 or later. Options can be configured interactively, through `PERLDB_OPTS`, or in `.perldb` files; the documentation also describes a GUI option through Devel::ptkdb. Perl is listed for Linux, macOS, and Windows, and the debugger is free. Some boundaries matter: compile-time statements such as `BEGIN`, `UNITCHECK`, `CHECK`, and `use` are not stopped, and functions not compiled by Perl, such as C or C++ extensions, do not provide stack-frame information. The debugger also does not currently work with Perl’s `-W` switch.
Who it suits
Perl Debugger suits developers diagnosing Perl programs who want to step through execution, inspect values, or pause at conditional breakpoints. It applies to Perl code and requires a program that compiles correctly.
Good to know, and what to watch
- Included with Perl and free to use
- Supports stepping into or over subroutine calls
- Conditional breakpoints and global-expression watches
- Can pretty-print nested data structures
- Program must compile before debugging
- Lexical-variable display requires PadWalker 0.08 or later
- Cannot provide stack frames for C or C++ extension functions
- Does not work with Perl's -W switch
Plans
Every plan and pricePerl Debugger
Free plan
Getting started
- Install Perl for Linux, macOS, or Windows
- Ensure the Perl program compiles correctly
- Run the program with Perl's -d flag
- Set breakpoints, watches, or stepping commands interactively
- Optionally configure PERLDB_OPTS or a .perldb file
- Optionally launch Devel::ptkdb with perl -d:ptkdb
Limits to check
The debugger cannot stop compile-time executable statements such as BEGIN, UNITCHECK, CHECK, and use, although AutoTrace can trace some compile-time code. It cannot show stack-frame information for functions not compiled by Perl, including C or C++ extensions; lexical-variable display requires PadWalker 0.08 or newer.
The verdict
Perl Debugger provides core interactive controls for examining Perl execution without a separate purchase or program. Its compile-time, native-extension, and `-W` limitations are worth checking against the issue being debugged.
Questions people ask
How much does Perl Debugger cost?
The Perl Debugger plan is free. It is included with Perl, and the pricing model is free.
Which operating systems are supported?
It is available for Linux, macOS, and Windows.
What language does it debug?
It debugs Perl programs.
Does it support conditional breakpoints and watches?
Yes. You can set conditional breakpoints and watch global expressions for changes.
Can it inspect lexical variables?
Yes, with PadWalker version 0.08 or higher.
Is there a graphical interface?
The documentation describes using the Devel::ptkdb GUI through `perl -d:ptkdb`.
What the maker publishes
- Breakpoints and watches
- Users can set conditional breakpoints and watch global expressions for changes. source
- 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. source
- Compile requirement
- The code must compile correctly for the debugger to work on it. source
- 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. source
- 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`. source
- Customizable
- Debugger options can be set interactively, through the PERLDB_OPTS environment variable, or in customization files. source
- Customization
- Options can be set interactively, through `PERLDB_OPTS`, or in `.perldb` customization files. source
- Editor connections
- The LineInfo option provides a mechanism to interact with client editors or visual debuggers, with vi, emacs, and ddd given as examples. source
- GUI option
- The documentation describes debugging a program through the Devel::ptkdb GUI using `perl -d:ptkdb`. source
- Inspect and control execution
- Debugger commands can examine source code, set breakpoints, show stack backtraces, and change variable values. source
- Inspect values
- The x command evaluates an expression and pretty-prints nested data structures recursively. source
- Interactive evaluation
- Commands the debugger does not recognize are evaluated as Perl code in the current package. source
- 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. source
- Notable limit
- The debugger cannot provide stack-frame information for functions not compiled by Perl, such as those from C or C++ extensions. source
- Optional dependencies
- Lexical variable inspection requires PadWalker, and full command-line editing requires Term::ReadKey and a Term::ReadLine module. source
- Platform availability
- The Perl download page lists Perl as included on Unix/Linux and macOS, and provides a Windows option through Strawberry Perl. source
- Project licensing
- Perl is open source and is licensed under either the Artistic License or the GNU General Public License. source
- Purpose
- The Perl source debugger runs scripts interactively and lets users inspect source, set breakpoints, get stack backtraces, and change variable values. source
- 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. source
- Stepping and tracing
- Commands support single stepping, stepping over subroutine calls, and tracing execution. source
- Step through code
- The s command steps into subroutine calls, while n executes over them to the next statement. source
- Support
- The download page points learners to learn.perl.org and the Perl Community for help. source
- Threaded debugging
- The `-dt` invocation debugs a threaded program and is marked experimental. source
- Variable inspection
- The debugger can pretty-print nested data and display package variables; lexical-variable display requires PadWalker version 0.08 or higher. source
Checked against the maker's pages on 7 Oct 2026.