Debugging Perl/CGI Scripts

By default, Perl/CGI script will send the error to STDERR where it is the server standard error and normally it will store to the server Apache error log.

To setup private error_log from your Perl/CGI script, you may easily get them done with script below.

BEGIN {
use CGI::Carp qw(carpout);
open(LOG, “>>/home/mickgenie.com/logs/cgi-error.log”) or
die(“Unable to open cgi-error.log: $!n”);
carpout(LOG);
}

The carpout() used to call the error and send it to the log file that you set.

To setup error to send to browser,

use CGI::Carp qw(fatalsToBrowser);
die “Couldn’t open log file”;

Use the above script and it could send all the error to the Browser.