Please let me begin by saying I know next-to-nothing about CGI so take this
with a LUMP of SALT:

----- Original Message ----- 
From: "Matthias Kraatz" <[EMAIL PROTECTED]>
To: "Brent Clark" <[EMAIL PROTECTED]>
Cc: "Perl Beginners List" <[EMAIL PROTECTED]>
Sent: Monday, December 06, 2004 11:39 AM
Subject: Re: CGI


> Hi Brent,
>
> there are a few reasons that come to my mind why the code stopped
> working after transferring from another machine:
>
> 1) The shellbang line (e.g. "#!/usr/bin/perl") does not point to the
> actual perl binary on the local machine.
> 2) A newline problem, i.e. you binary copied from a unix to dos machine
> or vice versa.
> 3) A perl module called from your script is not found
>
> Check the error log again. Usually just before the "Premature end of
> script... " message, there is a more descriptive warning that might help
> you to find out why it bailed out.
>
> -Matthias
>

I've have successful used the code below to debug on the server. Syntax
errors simply display on the browser. Note however that until this code is
error free you need to know how to kill a run-away process.

#!/usr/bin/perl -w                                          << alter to suit

use CGI::Pretty qw();
use CGI::Carp qw(fatalsToBrowser);
use strict;
use warnings;

BEGIN {
  sub DisplayError {
    my($s_Error)=shift;
    my($s_Body)="\"$s_Error in $ENV{SCRIPT_NAME}\"\n\n";
    open (SOURCE,"<$ENV{SCRIPT_FILENAME}");
    while (<SOURCE>) {
      $s_Body.="$.: $_";
       };
    close (SOURCE);
    my($s_Q)=CGI->new();
    print $s_Q->header('text/html')
       ,$s_Q->start_html('Error!')
       ,$s_Q->hr()
       ,$s_Q->h1('Error!')
       ,$s_Q->comment('The error and the body of the offending script
follows:')
       ,$s_Q->p($s_Q->pre($s_Body))
       ,$s_Q->hr()
       ,$s_Q->end_html
       ;
     };
  CGI::Carp::set_message(\&DisplayError);
   } # BEGIN

use DBI qw(:sql_types);
use MUD;
# This should blow up

# Code follows

...





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to