auf.kante
Gunnar macht sich selbststaendig und fliegt auf
die Schnauze
wird erfolgreich. Wer mag darf zuschauen.
Gunnar is starting his business. He will certainly
fail succeed. You may watch.
auf.kante
Website sections
Home
Debugging Perl
Last changed: 2005-07-24 [7:52]
Content:

Notes on debugging perl scripts.
 
Back to Personal Wiki
Table of contents
Debugging basics
Debugging CGI scripts

Debugging basics

Perl can be easily debugged using Emacs. At least from the viewpoint of the occasional Perl programmer (which I am...)

Open the script that needs debugging and call the perl debugger:

M-x perldb

You may enter any command line arguments you want to call the script with and then the debugger will start the code.

The basic commands:

n: next step, step over subroutines
Once you selected this mode with 'n' you may use 'enter' to step through the code.
s: next step, step into subroutines
Once you selected this mode with 's' you may use 'enter' to step through the code.
b <function>
Set a breakpoint on function <function>. You may also use <Module>::<function> to set a breakpoint on the function in a specific module. Use 'c' to continue through the code until you reach the breakpoint.
B *
Remove all breakpoints.
R
Restart the debugging process with the same command line parameters.

Debugging CGI scripts

In order to debug CGI scripts you can append the variable values you would usually send with a POST as normal arguments to the perl script.

A specific example from the AutoPrime program: I call the script 'AutoPrimeWeb' with the parameter 'html=3' with the URL 'AutoPrimeWeb?html=3'. I can create the same situation on the command line by opening the script with emacs, run

# Start the debugger
M-x perldb

# The the CGI parameter
Run perldb (like this): perl /srv/www/htdocs/molgen/AutoPrime-2.0.1/cgi/AutoPrimeWeb html=3

# Set the breakpoint to the problematic function
b AutoPrimeWeb::process

# And continue the code to that point
c

PDF of this file

Back to Personal Wiki
Creative Commons-Lizenzvertrag
The content of this site is licensed under a Creative Commons 2.5 License [attribution, share-alike]