#--------------------------------------------------- # subroutine bomb # a somewhat ungracefull way to end the execution of the cgi sub bomb { my $error_text = shift; print "\nHo Boy! A nasty error has occured: "; #extra \n to close off the HTTP header print $error_text; print "\n"; my @mail; if ($MAIL_BOMB_LIST ne '') { &printbomb(\@mail,$error_text); @BombRecipients = split (/,/, $MAIL_BOMB_LIST); my $submission = join '',@mail; $submission = "\n\n".$submission; $sent = &send_mail ($BombSMTPServer, $submission, 'CGI_Bomber@acme.com', "CGI $ENV{'SCRIPT_NAME'} bombed.", $BombReplyto, @BombRecipients); } exit; } # load error message and backtrace into @$array sub printbomb { my $array = shift; my $message = shift; my($syserror) = $!; push @$array, <<"EOM"; The CGI script $ENV{'SCRIPT_NAME'} seems to be having trouble! Error Message: $message Sys Error is: $syserror EOM my $i = 2; # start back 2 so as not to print bomb & printbomb stack frames. push @$array, "Backtrace:\n"; push @$array, " Subroutine name | Line | File \n"; push @$array, "----------------------|------|-------------------------------------------------\n"; while(($pack,$file,$line,$subname) = caller($i++)) { push @$array, sprintf("%21s |%5s |%50s\n",$subname,$line,$file); } }