Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Debugging CGI/PERL

by osunderdog (Deacon)
on Mar 21, 2007 at 16:56 UTC ( #605889=note: print w/replies, xml ) Need Help??


in reply to Debugging CGI/PERL

I've been here, and it's sometimes difficult. However you should try the -debug option available on the CGI pacakges... Of course I'm assuming you're using that.

Use the following use statement to enable debugging:

use CGI qw/:standard -debug/;

Then run the cgi through perl using the debugger settings:

perl -d mycgi.pl

Then you will have to pass cgi parameters. As value pairs. The perldoc for CGI goes into this -- search for 'debugging'.

Also, if there's a point in the flow that you come back to for debugging, you could write out the CGI context to a file . Then subsequently read that context back in to bring you back to a point where you want to debug. restore_parameters is documented in the perldoc.

Finally, and this one takes a little work, but you could possibly force the perl/tk debugger to come up. First you would have to start out your cgi with the following shebang:

#! perl -d:ptkdb

HOWEVER. For this to work you would have to allow any xwindow display to open on your desktop. And you would have to have the DISPLAY environment variable set for apache or by apache before the CGI is invoked... It's hard to setup, but it would give you the best debug situation you could imagine.

It would also help if you had a few

$DB::single=1;
lines scattered through the code that you want to debug.

Just a few thoughts that might get you where you want to be.

Hazah! I'm Employed!

Replies are listed 'Best First'.
Re^2: Debugging CGI/PERL
by tonyc (Pilgrim) on Mar 22, 2007 at 02:28 UTC

    For debugging with ptkdb you can put the setting of DISPLAY in a BEGIN block:

    BEGIN { $ENV{DISPLAY} = '192.168.32.50:0' }

    since ptkdb doesn't try to display a window until after compilation is complete.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://605889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2020-12-01 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?