in reply to Re: perl,cgi and apache woes
in thread perl,cgi and apache woes
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: perl,cgi and apache woes
by vinforget (Beadle) on Oct 03, 2003 at 17:23 UTC |