use CGI::Carp qw/fatalsToBrowser/; sub cgierr{ my ($error, $nolog) = @_; if ( $config{'debug'}==-1 ){ #### TBD: generic error report goes here # return 1; exit; } print $in->header(); #Begin detailed error and debug reporting if ($config{'debug'}) { print "
\n\nDEBUG\n==========================================\n";
    }
    else {
        print "
\n\nCGI ERROR\n==========================================\n";
    }

    $error    and print "Error Message       : $error\n";
    $0        and print "Script Location     : $0\n";
    $]        and print "Perl Version        : $]\n";

    $random_variable_I_want_to_see  and print "random variable I want to see        : $random_variable_I_want_to_see\n";
    
    print "\n\nInput Parameters\n-------------------------------------------\n";
    foreach $key (sort $in->param) {
       my $space = " " x (20 - length($key));
       print "$key$space: " . $in->param($key) . "\n";
    }
    print "\nCookies\n-------------------------------------------\n";
    print "\n$config{'userpass_cookie_name'} : " . $in->cookie($config{'userpass_cookie_name'});
    print "\n$config{'userid_cookie_name'} : " . $in->cookie($config{'userid_cookie_name'});
    print "\n$config{'back_do_cookie_name'} :   " . $in->cookie($config{'back_do_cookie_name'});

    print "\nEnvironment Variables\n-------------------------------------------\n";
    foreach $env (sort keys %ENV) {
        my $space = " " x (20 - length($env));
        print "$env$space: $ENV{$env}\n";
    }

    print "\nStack Trace \n-------------------------------------------\n";
    my $i = 0;
    while (my ($file, $line, $sub) = (caller($i++))[1,2,3]) {
        print qq!($sub) called from ($file) line ($line)
\n!; } print "\n
"; &log_action ("CGI ERROR: $error") if (!$nolog and $config{'logfile'}); exit; } #### <..lines of code..> &cgierr("fatal undef error: $@", 1);