You are using a browser which is not compatible with CSS (for more information, see Tara's tutorial).
Because of this, it is possible that our website may not appear
correctly in your browser. We apologise for the inconvenience, and
recommend you upgrade your browser to one which is compatible with CSS.
For more information, please visit our Browser Upgrade page.
By default, error messages are sent to STDERR. Most HTTPD servers direct STDERR to the server's error log. Some applications may wish to keep private error logs, distinct from the server's error log, or they may wish to direct error messages to STDOUT so that the browser will receive them.
The carpout() function is provided for this purpose. Since carpout() is not exported by default, you must import it explicitly by saying:
use CGI::Carp qw(carpout);
The carpout() function requires one argument, which should be a reference to an open filehandle for writing errors. It should be called in a BEGIN block at the top of the CGI application so that compiler errors will be caught.
Example:
#!/usr/bin/perl -w
BEGIN {
use CGI::Carp qw(carpout);
open(LOG, ">>/path/to/logs/dir/mycgi.log") or
die("Unable to open mycgi.log: $!\n");
carpout(LOG);
}
Note: carpout() does not handle file locking on the log for you at this point.
The real STDERR is not closed -- it is moved to SAVEERR. Some servers, when dealing with CGI scripts, close their connection to the browser when the script closes STDOUT and STDERR. SAVEERR is used to prevent this from happening prematurely.
If you want to send fatal (die, confess) errors to the browser, ask to import the special "fatalsToBrowser" subroutine:
#!/usr/bin/perl -w
use CGI qw /:standard center/;
use CGI::Carp qw(fatalsToBrowser);
Fatal errors will now be echoed to the browser as well as to the log. CGI::Carp arranges to send a minimal HTTP header to the browser so that even errors that occur in the early compilation phase will be seen. Nonfatal errors will still be directed to the log file only (unless redirected with carpout).
© 4WebHelp and Jos
Add a new comment