charbort
01-27-2003, 09:01 PM
This is my first time writing Perl so bear with me. The Perl loop is to send an email for each subject (checked box from a form). Currently, the html form is sending the subject1-subject5 in the body of the emails as below. How do I get the perl to enter the values into the array I defined as @subjects and how does the loop look?
Thanks,
Charbort
------ currently subjects are in the email body --
subject1: Subscribe Wildlife
subject2: Subscribe Fishing
subject3: Subscribe Heritage
subject4: Subscribe Nongame
subject5: Subscribe Urban
------- my perl code ----
sub send_mail {
# Define arrays for the form subject values. #
@subjects = ('subject1','subject2','subject3','subject4','subject5');
# Localize variables used in this subroutine. #
local($print_config,$key,$sort_order,$sorted_field,$env_report);
# Open The Mail Program
open(MAIL,"|$mailprog");
# Check for Message Subject
foreach $subject (@subjects)
{
print MAIL "To: $Config{'recipient'}\n";
print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
print MAIL "Subject: $subject\n\n"
print MAIL "Below is the result of your feedback form. It was submitted by\n";
print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
print MAIL "-" x 75 . "\n\n";
}
if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config: $Config{$print_config}\n\n";
}
}
}
Thanks,
Charbort
------ currently subjects are in the email body --
subject1: Subscribe Wildlife
subject2: Subscribe Fishing
subject3: Subscribe Heritage
subject4: Subscribe Nongame
subject5: Subscribe Urban
------- my perl code ----
sub send_mail {
# Define arrays for the form subject values. #
@subjects = ('subject1','subject2','subject3','subject4','subject5');
# Localize variables used in this subroutine. #
local($print_config,$key,$sort_order,$sorted_field,$env_report);
# Open The Mail Program
open(MAIL,"|$mailprog");
# Check for Message Subject
foreach $subject (@subjects)
{
print MAIL "To: $Config{'recipient'}\n";
print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
print MAIL "Subject: $subject\n\n"
print MAIL "Below is the result of your feedback form. It was submitted by\n";
print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
print MAIL "-" x 75 . "\n\n";
}
if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config: $Config{$print_config}\n\n";
}
}
}