Reputation: 8917
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?
Upvotes: 12
Views: 17223
Reputation: 41
There is a Perl module called "ptkdb" which is a standalone Perl interactive debugger. It works using the Tcl/Tk GUI, so you'll need that, too.
Depending on your OS you'll need to add some required modules.
Invoke it using
perl -d:ptkdb <your script>
If running some Unix/Linux system, you also need an X server.
Upvotes: 4
Reputation: 1541
There are two ways. The first is the one which Hachi and llioin already gave which is using the command-line switch "-d".
Or use an IDE. I am tried and used Komodo IDE which works like charm.
Upvotes: 1
Reputation: 6872
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.
Upvotes: 3
Reputation: 881123
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).
Upvotes: 31