The debugger uses the concept of a current display line. The current
display line is simply the last line that has been displayed
by the l command. When the
debugger first starts, the current display line is the first executable
line. Here are some examples.

Note
This listing is identical to Listing 14.5 except that the guts of the functions have been removed. This was done simply to shorten the listing.

If you load this script into the debugger (perl
-d 16lst01.pl), you will see that the first displayed
line is line 6. The lines before line 6 are package
and function statements.
Line 6 will also be the current execution line.

After this display, the current display line is changed to 15,
but the current execution line is still line 6. If you issue the
l debugger command again,
lines 16 to 20 are displayed.

You can display the first line of your script by using the l
1 debugger command. This command displays the first
line of the script and changes the current display line:

1: package Inventory_item;

Because this script uses package names to change the namespace
in which the functions are defined, simply issuing l
new does not display a new()
function. Instead, you need to use the double-colon (::)
notation to specify which namespace to use. For example, l
Color::new displays:

16: sub new {
17: }

While inside the debugger, you can use the X
and V commands to view variables.
These commands are very good for simple variables, but I have
not found them to be useful for complex data structures. For example,
consider a small program that creates an array within an array data
structure, debug5.pl.

Note
This listing is for illustrative purposes only. The crude method used to print the data structure is not recommended for practical use. I suggest that you invest time creating a general-use routine that can print more than one type of complex
structure.
You might also look at the dumpvars module that comes with most, if not all, Perl distributions.

Load this script into the debugger (perl
-d 16lst01.pl), use the s
command to execute the array assignment, and then display @array
with the X array command.
Your display should look like this:

@array = (
0 '1'
1 '2'
2 '3'
3 'ARRAY(0x7c693c)'
4 '4'
)

You can see that the displayed values are not as informative as
you might hope for because of the array reference in element 3.
However, because the prtArray()
function is designed to print this type of data structure, call
it from the debugger using the prtArray(@array);
command. This should result in a display like this:

0 '1'
1 '2'
2 '3'
0 '1'
1 '2'
2 '3'
4 '4'

The 1; line of code is used
to let you execute the array assignment without the debugger ending.
Just ignore it.