The Graphical Debugger included with the Perl Dev Kit is a lightweight yet
powerful GUI debugger for Perl scripts. To start the debuggger, simply enter
perl -d at the command prompt. The Perl Debugger settings, including
breakpoints and bookmarks, persist from one session to another.
Some of the key features of the Perl Debugger include:
After installing the Perl Dev Kit, start debugging your Perl programs by
running Perl with the -d option, as follows:
perl -d <myprogram>
...where <myprogram> is the Perl program to be debugged.
The pdkdebug utility is used to configure the Graphical Debugger, to set
the debug listener to local or remote mode, and to install (or uninstall) the
debug listener as a service.
For a list of the options available, enter:
pdkdebug --help
To view the current mode of the debug listener, enter:
pdkdebug --query
To set the debug listener to local mode, enter:
pdkdebug --local
To set the debug listener to remote mode, enter:
pdkdebug --remote
Use the --addr and --port switches to specify the address and port on
which the service should listen. Specify either the machine name or the IP
address for --addr. For example:
pdkdebug --remote --addr 192.168.1.3 --port 2000
...runs the Graphical Debugger in remote mode, listening on IP address 192.168.1.3, port 2000. These are the same values used in the 'PERLDB_OPTS=RemotePort=<IP>:<Port>' environment variable on the remote machine.
When you change the --addr or --port setting, the pdkdebug service is
automatically restarted if it is already running.
To run the debug listener interactively, do not specify the --remote switch.
If no hostname is specified for the --addr switch, the debug listener will
listen on all interfaces of the local machine. The --port option defaults
to 2000 if not specified.
Use the pdkdebug utility to configure the local debugger. Usage:
pdkdebug [--local] [--remote] [-addr [x.x.x.x]] [--port [portnumber]]
[--help] [--install] [--remove]
--remote option.
--local option.
pdkdebug utility.
To install the debug listener as a service, enter:
pdkdebug --install
To manually start the service after installing it, enter:
net start pdkdebug
To automatically start the service after installing it, enter:
pdkdebug --install auto
The 'auto' switch causes the service to restart every time the operating system is restarted.
To remove the service, enter:
pdkdebug --remove
After the Perl Dev Kit is installed, the PDK's Graphical Debugger becomes the default debugger, replacing the console debugger included with your Perl distribution.
To disable the Graphical Debugger included with the Perl Dev Kit and use the console debugger instead, perform the following steps:
pdkdebug --query to view the current mode. If necessary, enter
pdkdebug --local to set the debug listener to local mode.
set PERL5DB=BEGIN { require 'perl5db.pl' }
The source code of the Perl program is displayed in the Source window. Generally, this is the Perl program specified when you started the Perl debugger; however, if another Perl program is called during the execution of the original program, the program that is currently running is displayed in the Source window. The program is displayed line by line, and Perl syntax is colored according to the configuration of the Color tab in the Options dialog box.

To make the source window the active window, click anywhere in the window, or press 'Alt'+'S' or 'F6'.
The left margin displays breakpoint markers, bookmark markers, the Current Line Pointer, and the Instruction Pointer. The margin also displays line numbers (if this option has been enabled on the Source tab in the Options dialog box).
The Current Line Pointer can be moved via the standard keyboard navigation keys: 'Up Arrow', 'Down Arrow', 'Home', 'End', 'Page Up' and 'Page Down'. Press the 'Ctrl' key to scroll the window vertically without moving the Current Line Pointer.
The Current Line Pointer can also be moved by clicking the mouse on the desired line. Right-click or press 'Shift'+'F10' to display a shortcut menu is displayed that contains the following commands: Toggle Breakpoint, Insert Breakpoint, Edit Breakpoints, Run to Cursor and Quick Eval.
Double-clicking a variable in the Source window selects the variable. Right-clicking the selected variable displays a shortcut menu from which you can choose Quick Eval, Copy to Watch or Copy to Clipboard.
Double-clicking a line number in the margin toggles a breakpoint on that line.
On the right side of the Status Bar there are two message boxes. Double-clicking the message on the left displays the Go To Line dialog box. The second message box displays 'Ready' when the debugger is idle, and 'Working' when a program is running.
The Watch window displays one or more Perl expressions in the context of the Perl program that is currently running.

The result of each expression in the Watch window is updated any time a variable, in the context of the Perl program, could potentially change. Updates occur after execution is continued, when a statement is stepped over, or after the Quick Eval dialog box is used. The expressions supported are the same as those supported by the Quick Eval dialog box. Note that these expressions are evaluated from top to bottom and that expressions in the Watch window are evaluated before expressions in the Registers window.
To make the Watch window the active window, either click anywhere in the window or press 'Alt'+'W'.
To add variables to the Watch window, use one of the following methods:
You can also add variables to the Watch window by selecting the variable that you want to add in the Source window, right-clicking it, and then clicking Copy to Watch on the shortcut menu.
Edit a watch by doing any of the following:
Remove a watch by doing any of the following:
Right-clicking the border of the Watch window displays a menu with commands for docking and hiding the window.
Move the Watch window to any position on your screen by clicking the border of the window and dragging it to the desired location. To prevent the window from docking, hold down the 'Ctrl' key while dragging the window.
The Proximity window looks and behaves much like the Watch and Registers windows, except that you cannot change the list of expressions. Instead, the list is automatically generated by the debugger, which looks at the lines of the Perl program surrounding the current statement. Specify the number of lines above and below the Instruction Pointer to scan for variables by changing the lines above and lines below options in the Watch tab of the Options dialog box.

To make the Proximity window the active window, click anywhere in the window or press 'Alt'+'P'.
Right-click in the Proximity window to display a shortcut menu with commands for hiding the Proximity window and copying the currently selected variable to the Watch window.
Right-click the border of the Proximity window to display a shortcut menu that with commands for enabling docking of the window and hiding the window.
Move the Proximity window to any position on your screen by clicking the border of the window and dragging it to the desired location. To prevent the window from docking, hold down the 'Ctrl' key while dragging the window.
The Registers window looks and behaves exactly like the Watch window. The only significant difference between the two is that the expressions listed in the Registers window are tied to the application instead of the currently active Perl program, making them the same for every Perl program you debug. Any changes made to the list of expressions in this window will be reflected the next time the debugger is run, regardless of the script.

The result of each expression in the Registers window is updated any time a variable, in the context of the Perl program, could potentially change. Expressions are updated after execution resumes, after a statement is stepped over, or after the Quick Eval dialog box is used. The expressions supported are the same types as those supported by the Quick Eval dialog box. Note that the expressions are evaluated from top to bottom and that expressions in the Watch window are evaluated before expressions in the Registers window.
To make the Registers window the active window, click anywhere in the window or press 'Alt'+'W'.
To add variables to the Registers window, use one of the following methods:
Edit a watch by doing any of the following:
Remove a watch in any of the following ways:
Right-clicking in the border of the Registers window displays a menu that lets you hide the window and enable docking of the window.
Move the Registers window to any position on your screen by clicking on the border of the window and dragging it to the desired location. To prevent the window from docking, hold down the 'Ctrl' key while dragging the window.
The Tool Bar conveniently groups the most commonly used debugger functions. The function of each of the icons and their corresponding shortcut keys are listed below.
If the debugger is running, the executing Perl program will not automatically terminate and will probably have to be stopped manually using 'Ctrl'+'C'.
When the application is exited, various application settings are saved to the registry, including:
Various settings associated with the current Perl program are also saved, including the list of variables in the Watch window, the breakpoints and their conditions, and the current bookmarks.
Note: If the Reset All Settings button in the Options dialog box has been pressed, instead of saving all of the above settings, the entire Perl Debugger registry key is deleted. All of the the debugger settings will revert to the default when the debugger is next launched.
Any Perl expression can be successfully evaluated with this dialog box,
including assignments, which can be used to change variables. More
specifically, any expression that is syntactically correct inside
parentheses works with this dialog box. As a result, neither blocks nor
multiple statements separated by semicolons are supported. Also, a match or
substitution evaluated with this dialog box does not affect the global match
variables ($&, $1, etc). To view the results of a match, for example,
you must include them in the evaluation in some way, as in /([a-z]+)/, $1.
The Dump Variable dialog box displays the contents of a specified variable in
the context of the currently executing Perl program. This dialog box calls the
dumpvar subroutine provided by Perl 5.x. The text specified in the
Variable box can be a scalar, array, hash or even a file handle. The $, @
or % is stripped from the variable before it is passed to dumpvar, so if
the specified variable name is used by both an array and a hash, for example,
the contents of both the array and the hash are displayed. See the
implementation of the dumpvar subroutine for a more complete description
of what is supported.
Each entry in the list of subroutine calls includes the name of the subroutine, the arguments that were passed to the subroutine (if any), and the file and line from which the subroutine was called. The Go To Line button is enabled when a subroutine call from the currently active Perl program is selected. Pressing the Go To Line button, or double-clicking a subroutine call item, closes the Call Stack dialog box and sets the current line to the line number specified by the selected subroutine call in the call stack.
To customize the Perl Debugger, on the Tools menu, click Customize. The Customize Tools dialog box displays the list of User Tools currently available, and allows you to add, remove or change the list of User Tools. The Edit Source option on the Tools menu is the default tool and can be configured to launch your favorite editor.
You can add up to 16 tools and run them by either selecting the entry from the Tools menu or pressing 'Alt'+'1-9' for tools 1 through 9, 'Alt'+'0' for tool 10, and 'Alt'+'Shift'+'1-6' for tools 11 through 16. The names of the tools currently available are shown in the User Tools list. Selecting a tool displays the Name, Command, Arguments and Initial Directory for that tool.
The four buttons above the User Tools list allow you to add, remove and change the order of the tools. Clicking the Add button or pressing 'Alt'+'N' adds a new tool to the bottom of the list with the name "New Tool".

To add a new tool:
The Arguments text box displays the arguments that will be passed to the program specified in the Command text box when the tool is selected from the Tools menu. The following strings with additional information can be passed:
You can change the order in which the entries appear on the Tools menu by selecting the entry in the Customize Tools dialog box and clicking either the up or down arrow located in the upper right corner.
To delete an entry, select the entry and either press 'Delete' or press the Delete button located in the upper right corner of the Customize Tools dialog box.
Any changes made take place immediately - there is no way to undo any changes made in this dialog box.
On the Tools menu, click Options, and then click the General tab to view general configurable properties. While editing options in the Options dialog box, click OK to apply the changes. Click Cancel to discard any changes.

Display Splash Screen: This check box controls whether the splash screen displays when you start ActiveState's Perl Debugger.
Reset All Settings: Click this button to discard any changes you have made to the settings, including window placement and breakpoints. This deletes settings not only for the current script, but also any other scripts you have run. (Settings are stored for as many as 100 scripts).
On the Tools menu, click Options, and then click on the Source tab to configure how you view your source. When editing options in the Options dialog box, click OK to apply the changes. Click Cancel to discard any changes. Clicking the Reset All settings button on the General tab returns all of the settings to their defaults.

On the Tools menu, select Options, and then click the Watch tab to view the configurable watch properties. When editing options in the Options dialog box, click OK to apply the changes. Click Cancel to discard any changes. Clicking the Reset All settings button on the General tab returns all of the settings to their defaults.

On the Tools menu, select Options, and then click the Colors tab to view the configurable color properties. When editing options in the Options dialog box, click OK to apply the changes. Click Cancel to discard any changes. Clicking the Reset All settings button on the General tab returns all of the settings to their defaults.

Enable Syntax Coloring is used to set colors for the various categories of syntax in the Perl program. The components are divided into the following categories:
=cut.
String also determines the color that double-quoted strings are displayed in. Double-quoted strings can start with a non-backslashed double-quote and end with a non-backslashed double-quote. Double-quoted strings can also start with 'qq'. (The syntax is the same as 'q' for single-quoted strings.)
Even though the Perl Debugger is running on a Windows machine, Perl scripts residing on any machine that supports Perl 5.005_03 or later can be debugged, including Linux, Solaris, HP-UX, AIX, etc.
The requirements for the remote machine vary according to its version of Perl:
libnet module from CPAN or the ActiveState repository
The environment variable PERLDB_OPTS must point to the port where the Perl Dev Kit Perl Debugger is running. The format of the environment variable is:
PERLDB_OPTS=RemotePort=I<IP_or_hostname>:I<Port>
...where IP_or_hostname is the IP address or hostname of the machine where the Perl Debugger resides, and Port is the port used for the connection.
Examples:
PERLDB_OPTS=RemotePort=192.168.188.20:2000
...tells the remote machine to connect to the Perl Debugger running at IP address 192.168.188.20 on port 2000.
PERLDB_OPTS=RemotePort=awl.ActiveState.com:2000
...tells the remote machine to connect to the Perl Debugger running at hostname awl.ActiveState.com on port 2000.
There are two ways to start the debugger:
-d command-line switch.
-d switch is specified on the #! line, as is the case when a Perl script
is called from a web server.
Note: Due to a bug in the Windows Me/98/95 command shell, you cannot set PERLDB_OPTS as an environment variable on Windows Me/98/95. This setting must be made in the Windows registry. The registry entry is HKLM\Software\Perl\PERLDB_OPTS.