Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run through a Perl program step by step?

Tags:

debugging

perl

I have a Perl program written by someone else. When I run it, it silently exits without writing anything to the logfile. Is there a way I can run this Perl program step by step, line by line by the interpreter and thus get to see where it terminates?

like image 262
xyz Avatar asked Jan 19 '12 08:01

xyz


2 Answers

Yes, there is the Perl debugger which you can invoke with perl -d.

Documentation can be found in perldoc perldebug and perldoc perldebtut.

Probably the most useful commands would be:

s                 - step into current line.
n                 - step over current line.
r                 - step out of current function.
p <expr>          - print the expression.
b <line|subnm>    - sets a breakpoint
T                 - produce a stack trace.
c [<line|subnm>]  - continue running with optional one-time breakpoint.
h                 - help (for other commands).
like image 145
paxdiablo Avatar answered Oct 20 '22 18:10

paxdiablo


Hachi has the answer. Use the Perl debugger by running perl with the -d flag. For information on how to use the debugger past starting it, see the Perl Debugging Tutorial.

like image 33
Ilion Avatar answered Oct 20 '22 18:10

Ilion