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!


In reply to Re: Debugging CGI/PERL by osunderdog
in thread Debugging CGI/PERL by Trihedralguy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.