Debugging CGI Using ptkdb

ptkdb is a graphical Perl debugger. To use it when debugging command line scripts is very straight forward. Just type in the command line:


perl -d:ptkdb script.pl

and you’re good to go.

However, using it to debug CGIs needs some tweaking to your CGI source. Replace the usual

#!/usr/bin/perl

line at the top of the CGI script with this one:


#!/usr/bin/perl -d:ptkdb
BEGIN {$ENV{DISPLAY} = "$ENV{REMOTE_ADDR}:0.0";}

Go to your browser and invoke your CGI and a debugger window should pop up.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.