Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Why server error out with module

by pryrt (Abbot)
on Oct 26, 2020 at 15:38 UTC ( [id://11123187]=note: print w/replies, xml ) Need Help??


in reply to Why server error out with module

Adding use CGI::Carp qw(fatalsToBrowser); during debug can help (especially if hippo's suggestion of searching ISP error logs isn't convenient).

And, in the BEGIN block, you might want to log some of the CGI header variables from %ENV, like $ENV{SERVER_ADDR}, possibly to your own logfile or to STDERR, or move your $cgi->header print so that it's in the BEGIN before the unshift -- it might indicate that your ISP has a round-robin of servers where one or more servers aren't behaving identically to the others, or some such. By putting it as early as possible (in BEGIN blocks, before local libraries are used), you increase the chances that your debug code will be printed somewhere you can read it before the script crashes.

An example here:
#!/usr/bin/perl -w use strict; use warnings; use CGI; use Data::Dumper; use CGI::Carp qw(fatalsToBrowser); my $cgi; BEGIN{ $cgi = CGI->new; print $cgi->header; unshift @INC, "/var/www/vhosts/myDomain.com/secured.myDomain.com/c +gi-bin/library"; # pick one of print STDERR $ENV{SERVER_ADDR}, "\n"; # to ISP error log # or print $ENV{SERVER_ADDR}, "\n"; # to browser -- that's why I move +d the cgi->header print to above, in the BEGIN # or open my $logfile, '>>', 'writable/path/to/logfile.txt' or die "err +or appending to logfile"; print {$logfile} $ENV{SERVER_ADDR}, "\n"; # to your own error lo +g # other possible environment variables listed at http://www.cgi101 +.com/book/ch3/text.html } use doctypeAndHeader; header();

http://www.cgi101.com/book/ch3/text.html lists other interesting environment variables, and a way to dump all of the %ENV... SERVER_ADDR isn't in their list, but it's available on my shared hosting system.


edits: fix typos and links

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-19 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found