Building on chromatic's advice, I wanted to add that you will speed your development time if you add something extra to your CGI script. At the top of the script:

use CGI::Carp qw( fatalsToBrowser );

This enables you to redirect those error messages from your server's logfile directly to the browser window. This may or may not be appropriate once the application is put into final end-user-use. But during development it definately saves you from running to the server error log every 30 seconds.

Once you've placed that line in your file, you need to also supply a error redirect subroutine. Here's the one I use (thanks to CGI Programming with Perl, from O'Rielly).

BEGIN { sub carp_error { my $error_message = shift; my $cq = new CGI; print $cq->start_html( "Error" ), $cq->h1("Error"), $cq->p( "Sorry, the following error has occurred: " ), $cq->p( $cq->i( $error_message ) ), $cq->end_html; } CGI::Carp::set_message( \&carp_error ); }

That ought to do it.

You may already know this but the CGI.pm module allows you to run your CGI scripts from the command line, so that the output goes straight to <STDOUT> (your terminal screen). If you need to set certain key=>value parameters to test how the script reacts, you do that directly from the command line too. See the CGI.pm POD for more info. I find that also to be an invaluable debugging tool.


Dave


"If I had my life to do over again, I'd be a plumber." -- Albert Einstein

In reply to Re: Re: perl,cgi and apache woes by davido
in thread perl,cgi and apache woes by vinforget

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.