Hi, can anybody tell me whats wrong with this code. I get an error message saying bad email
sub holdval_delete_records {
# --------------------------------------------------------
# Deletes a single or multiple records. First the routine goes thrrough
# the form input and makes sure there are some records to delete. It then goes
# through the database deleting each entry and marking it deleted. If there
# are any keys not deleted, an error message will be returned saying which keys
# were not found and not deleted, otherwise the user will go to the success page.
my ($key, Þlete_list, $rec_to_delete, @data, $errstr, $succstr, $output, %links, @lines, $id, $first, $last, $rec_to_reenter, %reenter_list, %hold_list, @holdhits, $numhits, $counter);
$rec_to_delete = 0;
foreach $key (keys %in) { # Build a hash of keys to delete.
if ($in{$key} eq "delete") {
$delete_list{$key} = 1;
$rec_to_delete = 1;
}
}
$rec_to_delete or (&html_generic("Error: $html_object(s) Not Deleted", "no records specified.") and return);
# Search the database for a record to delete.
open (DB, "<$db_hold_name") or &cgierr("error in delete_records. unable to open db file: $db_hold_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and ($output .= $_ and next LINE);
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= "$_\n"); # otherwise print it.
}
close DB;
# Reprint out the database.
open (DB, ">$db_hold_name") or &cgierr("error in delete_records. unable to open db file: $db_hold_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_hold_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock
# Build success/error messages.
foreach $key (keys Þlete_list) {
$delete_list{$key} ? # Check to see if any items weren't deleted
($errstr .= "$key,") : # that should have been.
($succstr .= "$key,"); # For logging, we'll remember the one's we deleted.
}
chop($succstr); # Remove trailing delimeter
chop($errstr); # Remove trailing delimeter
*****wrong*****
# Before we display the HTML, let's fire off some re-enter/delete emails
# NOTE: You can modify the text of the email in the email templates.
&html_print_headers; # Just in case sendmail coughs up an error.
ID: foreach $id (keys %hold_list) {
if ($hold_list{$id}) { next ID; }
elsif (!$in{"reason-$id"}) { next ID; }
elsif (${$links{$id}}{'Contact Email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
${$links{$id}}{'Contact Email'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
$errstr .= ($errstr, "<li>Email Error: <strong>$id</strong>. Record deleted, but couldn't send rejection letter. Reason: Bad Email addres: '${$links{$id}}{'Contact Email'}'.");
}
else { &html_reject_email (%{$links{$id}});
}
*********wrong********
# Now let's go to the error page or the success page depending on
# what $errstr is.
$errstr ?
&html_generic ("Re-enter or Deleting Links", "Error Deleting links: <ul>$errstr</ul>") :
&html_holdval_success($succstr);
}
}
Thanks all for your help...
sub holdval_delete_records {
# --------------------------------------------------------
# Deletes a single or multiple records. First the routine goes thrrough
# the form input and makes sure there are some records to delete. It then goes
# through the database deleting each entry and marking it deleted. If there
# are any keys not deleted, an error message will be returned saying which keys
# were not found and not deleted, otherwise the user will go to the success page.
my ($key, Þlete_list, $rec_to_delete, @data, $errstr, $succstr, $output, %links, @lines, $id, $first, $last, $rec_to_reenter, %reenter_list, %hold_list, @holdhits, $numhits, $counter);
$rec_to_delete = 0;
foreach $key (keys %in) { # Build a hash of keys to delete.
if ($in{$key} eq "delete") {
$delete_list{$key} = 1;
$rec_to_delete = 1;
}
}
$rec_to_delete or (&html_generic("Error: $html_object(s) Not Deleted", "no records specified.") and return);
# Search the database for a record to delete.
open (DB, "<$db_hold_name") or &cgierr("error in delete_records. unable to open db file: $db_hold_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and ($output .= $_ and next LINE);
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= "$_\n"); # otherwise print it.
}
close DB;
# Reprint out the database.
open (DB, ">$db_hold_name") or &cgierr("error in delete_records. unable to open db file: $db_hold_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_hold_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock
# Build success/error messages.
foreach $key (keys Þlete_list) {
$delete_list{$key} ? # Check to see if any items weren't deleted
($errstr .= "$key,") : # that should have been.
($succstr .= "$key,"); # For logging, we'll remember the one's we deleted.
}
chop($succstr); # Remove trailing delimeter
chop($errstr); # Remove trailing delimeter
*****wrong*****
# Before we display the HTML, let's fire off some re-enter/delete emails
# NOTE: You can modify the text of the email in the email templates.
&html_print_headers; # Just in case sendmail coughs up an error.
ID: foreach $id (keys %hold_list) {
if ($hold_list{$id}) { next ID; }
elsif (!$in{"reason-$id"}) { next ID; }
elsif (${$links{$id}}{'Contact Email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
${$links{$id}}{'Contact Email'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
$errstr .= ($errstr, "<li>Email Error: <strong>$id</strong>. Record deleted, but couldn't send rejection letter. Reason: Bad Email addres: '${$links{$id}}{'Contact Email'}'.");
}
else { &html_reject_email (%{$links{$id}});
}
*********wrong********
# Now let's go to the error page or the success page depending on
# what $errstr is.
$errstr ?
&html_generic ("Re-enter or Deleting Links", "Error Deleting links: <ul>$errstr</ul>") :
&html_holdval_success($succstr);
}
}
Thanks all for your help...