[thelist] foreach problem with Perl
Tony Grimes
algrimes@acs.ucalgary.ca
Sun Jul 22 23:03:45 2001
I need some perl help. I'm writing a script to automate multiple
majordomo subscriptions from a web form by sending an email using
sendmail. Everything's working fine except that an extra space is added at
the beginning of some of the lines in the final email (actually, every one
after the first line). Here is the body of the email in question:
<SNIP>
subscribe list1-l name@somewhere.com
subscribe list2-l name@somewhere.com
subscribe list3-l name@somewhere.com
</SNIP>
I think it might have something to do with a foreach block i'm using
to modify the original imported array. Here is the relevant code:
<SNIP>
my $c = new CGI;
my $email = $c->param("email");
my @lists = $c->param("listname");
foreach $list (@lists) {
$list="subscribe "."$list"." $email\n";
}
open MAIL, "|/usr/lib/sendmail -t -i"
or die "Could not open sendmail: $!\n";
print MAIL <<END_OF_MESSAGE;
To: mdomo\@somewhere.com
From: webmaster\@somewhere.com
Subject: Test
@lists
END_OF_MESSAGE
close MAIL or die "Could not close sendmail properly: $!\n";
</SNIP>
The web page containing the original form is here:
http://cgi.cadvision.com/~ppdmweb/development/listserv/index.html
Do any of the perl gurus out there know how to get rid of these extra
lines? I don't know if it'll affect majordomo but this is really bugging
me. Any help would be greatly appreciated.
.tony