I've got a simply mailer.cgi form processor by where I'm trying to have the functionality by where a specific drop down menu field emails specific email addresses. So that when the submit button is hit only certain people receive emails based on which dropdown menu selection they chose.

I've tried this for it gives me 500 internal server error:

if ($POST{'problem_category'{ eq "one"}
{ $send_mail = "info@mediaintentions.com";}
else if ($POST{'problem_category'} eq "two")
{ $send_mail = "info@bartonsprings.net";
}


The actual mailer.cgi scrip is the following:

#!/usr/bin/perl

$mailprog = '/usr/sbin/sendmail';

# Retrieve Date
&get_date;

# Parse Form Contents
&parse_form;

# Check Required Fields
&check_required;

# Return HTML Page or Redirect User
&return_html;

# Send E-Mail
&send_mail;

sub get_date {

@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');

#This is NOT Y2K compliant! This MUST be changed on Jan 1 2000 #
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 2000;

$date = "$days[$wday], $months[$mon] $mday, $year at $time";

}

sub parse_form {

%Config = ('recipient','', 'subject','',
'email','', 'realname','',
'redirect','', 'bgcolor','',
'redirect_emer','', 'Service Needed','',
'background','', 'link_color','',
'vlink_color','', 'text_color','',
'alink_color','', 'title','',
'sort','', 'print_config','',
'required','', 'env_report','',
'return_link_title','', 'return_link_url','',
'print_blank_fields','', 'missing_fields_redirect','');




if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);
}
else {
&error('request_method');
}

foreach $pair (@pairs) {

local($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

#SSI Block#
$value =~ s/<!--(.|\n)*-->//g;

if (defined($Config{$name})) {
$Config{$name} = $value;
}
else {
if ($Form{$name} && $value) {
$Form{$name} = "$Form{$name}, $value";
}
elsif ($value) {
push(@Field_Order,$name);
$Form{$name} = $value;
}
}
}

$Config{'required'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'required'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'env_report'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'env_report'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'print_config'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'print_config'} =~ s/(\s+)?\n+(\s+)?//g;

@Required = split(/,/,$Config{'required'});
@Env_Report = split(/,/,$Config{'env_report'});
@Print_Config = split(/,/,$Config{'print_config'});
}

sub check_required {

local($require, @error);

if (!$Config{'recipient'}) {
if (!defined(%Form)) { &error('bad_referer') }
else { &error('no_recipient') }
}

foreach $require (@Required) {

if ($require eq 'email' && !&check_email($Config{$require})) {
push(@error,$require);
}

elsif (defined($Config{$require})) {
if (!$Config{$require}) {
push(@error,$require);
}
}

elsif (!$Form{$require}) {
push(@error,$require);
}
}

if (@error) { &error('missing_fields', @error) }
}

sub return_html {
local($key,$sort_order,$sorted_field);

if (($Config{'Service Needed'} =~ /emergency/) && ($Config{'redirect_emer'})){
print "Location: $Config{'redirect_emer'}\n\n";
}

elsif ($Config{'redirect'}) {
print "Location: $Config{'redirect'}\n\n";
}

else {

print "Content-type: text/html\n\n";
print "<html>\n <head>\n";

if ($Config{'title'}) { print " <title>$Config{'title'}</title>\n" }
else { print " <title>Thank You</title>\n" }

print " </head>\n <body";

&body_attributes;

print ">\n <center>\n";

if ($Config{'title'}) { print " <h1>$Config{'title'}</h1>\n" }
else { print " <h1>Thank You For Filling Out Our Response Form</h1>\n" }

print "</center>\n";

print "Below is what you submitted to $Config{'recipient'} on ";
print "$date<p><hr size=1 width=75\%><p>\n";

if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {

if ($Config{'print_blank_fields'} || $Form{$field}) {
print "<b>$field/b> $Form{$field}<p>\n";
}
}
}

elsif ($Config{'sort'} =~ /^order:.*,.*/) {

$sort_order = $Config{'sort'};
$sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$sort_order =~ s/(\s+)?\n+(\s+)?//g;
$sort_order =~ s/order://;
@sorted_fields = split(/,/, $sort_order);

foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field}) {
print "<b>$sorted_field/b> $Form{$sorted_field}<p>\n";
}
}
}

else {

foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field}) {
print "<b>$field/b> $Form{$field}<p>\n";
}
}
}

print "<p><hr size=1 width=75%><p>\n";

if ($Config{'return_link_url'} && $Config{'return_link_title'}) {
print "<ul>\n";
print "<li><a href=\"$Config{'return_link_url'}\">$Config{'return_link_title'}</a>\n";
print "</ul>\n";
}

print <<"(END HTML FOOTER)";
<hr size=1 width=75%><p>
</body>
</html>
(END HTML FOOTER)
}
}

sub send_mail {
local($print_config,$key,$sort_order,$sorted_field,$env_report);

open(MAIL,"|$mailprog -t");

print MAIL "To: $Config{'recipient'}\n";
print MAIL "From: $Config{'email'}\n";
print MAIL "Cc: $Config{'email'}\n";

if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
else { print MAIL "Subject: Response Form Submission\n\n" }

print MAIL "The following information was submitted by\n";
print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
print MAIL "-" x 75 . "\n\n";

print MAIL " \n";
print MAIL "Service Needed: $Config{'Service Needed'}\n\n";

if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config: $Config{$print_config}\n\n";
}
}
}

if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {

if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0') {
print MAIL "$field: $Form{$field}\n\n";
}
}
}

elsif ($Config{'sort'} =~ /^order:.*,.*/) {

$Config{'sort'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'sort'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'sort'} =~ s/order://;
@sorted_fields = split(/,/, $Config{'sort'});

foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field} ||
$Form{$sorted_field} eq '0') {
print MAIL "$sorted_field: $Form{$sorted_field}\n\n";
}
}
}

else {

foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0') {
print MAIL "$field: $Form{$field}\n\n";
}
}
}

print MAIL "-" x 75 . "\n\n";

foreach $env_report (@Env_Report) {
if ($ENV{$env_report}) {
print MAIL "$env_report: $ENV{$env_report}\n";
}
}

close (MAIL);
}

sub check_email {
$email = $_[0];

if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||

$email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {

return 0;
}

else {

return 1;
}
}

sub body_attributes {
if ($Config{'bgcolor'}) { print " bgcolor=\"$Config{'bgcolor'}\"" }

if ($Config{'background'}) { print " background=\"$Config{'background'}\"" }

if ($Config{'link_color'}) { print " link=\"$Config{'link_color'}\"" }

if ($Config{'vlink_color'}) { print " vlink=\"$Config{'vlink_color'}\"" }

if ($Config{'alink_color'}) { print " alink=\"$Config{'alink_color'}\"" }

if ($Config{'text_color'}) { print " text=\"$Config{'text_color'}\"" }
}

sub error {
local($error,@error_fields) = @_;
local($host,$missing_field,$missing_field_list);

if ($error eq 'request_method') {
print <<"(END ERROR HTML)";
Content-type: text/html

<html>
<head>
<title>Error: Bad Request Method</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>Error: Bad Request Method</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><td>The Request Method of the Form you submitted did not match
either <tt>GET</tt> or <tt>POST</tt>. Please check the form and make sure the
<tt>method=</tt> statement is in upper case and matches <tt>GET</tt> or <tt>POST</tt>.<p>

<center><font size=-1>
</font></center>
</td></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}

elsif ($error eq 'no_recipient') {
print <<"(END ERROR HTML)";
Content-type: text/html

<html>
<head>
<title>Error: Missing Recipient</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>Error: Missing Recipient</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><td>No Recipient was specified in the data sent from the form. Please
make sure there is a 'recipient' form field with an email address.
<hr size=1>
<center><font size=-1>
</font></center>
</td></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}

elsif ($error eq 'missing_fields') {
if ($Config{'missing_fields_redirect'}) {
print "Location: $Config{'missing_fields_redirect'}\n\n";
}
else {
foreach $missing_field (@error_fields) {
$missing_field_list .= " <li>$missing_field\n";
}

print <<"(END ERROR HTML)";
Content-type: text/html

<html>
<head>
<title>Error: Missing Required Information</title>
</head>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>Error: Missing Required Information</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><td>The following information was left blank in your submissionp>
<ul>
$missing_field_list
</ul><br>

These fields must be filled in before you can successfully submit the form.<p>
Please use your browser's back button to return to the form and try again.<hr size=1>
<center><font size=-1>
</font></center>
</td></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}
}
exit;
}