1. Enter Perl Debugger

# perl -d ./perl_debugger.pl

it prompts,
DB<1>

2. View specific lines or subroutine statements using (l)

DB<1> l 10
10: my $pattern;

DB<2> l get_pattern
11 {
12: my $pattern;
13: print “Enter search string: “;
14: chomp ($pattern = );
15: return $pattern;
16 }

3. Set the breakpoint on get_pattern function using (b)

DB<3> b find_files

4. Set the breakpoint on specific line using (b)

DB<4> b 44

5. View the breakpoints using (L)

DB<5> L
./perl_debugger.pl:
22: my $pattern = shift;
break if (1)
44: print join “\n”,@list;
break if (1)

6. step by step execution using (s and n)

DB<5> s
main::(./perl_debugger.pl:39): $pattern = get_pattern();

DB<5> s
main::get_pattern(./perl_debugger.pl:12):
12: my $pattern;

Option s and n does step by step execution of each statements. Option s steps into the subroutine. Option n executes the subroutine in a single step (stepping over it).

The s option does stepping into the subroutine but while n option which would execute the subroutine(stepping over it).

7. Continue till next breakpoint (or line number, or subroutine) using (c)

DB<5> c
Enter search string: perl
main::find_files(./perl_debugger.pl:22):
22: my $pattern = shift;

8. Continue down to the specific line number using (c)

DB<5> c 36
main::find_files(./perl_debugger.pl:36):
36: return @list;

9. Print the value in the specific variable using (p)

DB<6> p $pattern
perl

DB<7> c
main::(./perl_debugger.pl:44): print join “\n”,@list;
DB<7> c
./perl_debugger.pl
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.

After the last continue operation, the output gets printed on the stdout as “./perl_debugger.pl” since it matches the pattern “perl”.

10. Get debug commands from the file (source)

Perl debugger can get the debug command from the file and execute it. For example, create the file called “debug_cmds” with the perl debug commands as,

c
p $pattern
q

Note that R is used to restart the operation(no need quit and start debugger again).
DB<7> R
DB<7> source debug_cmds
>> c
Enter search string: perl
./perl_debugger.pl
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
>> p $pattern
perl
>> q

Source: Perl Debugger Tutorial: 10 Easy Steps to Debug Perl Program