in reply to Sending email from a CGI script (was: sendmail)
to get the variable input. I'd consult OVID's tutorial mentioned above for the exact usage of the CGI module.use CGI; $fav_color = param("favorite_color");
You'd then call the subroutine with something like my %formdata = &parse_formsub parse_form { my (@pairs, $buffer, $value, $key, $pair); 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 { print "Content-type: text/html\n\n"; print "<P>Use Post or Get"; } foreach $pair (@pairs) { ($key, $value) = split (/=/, $pair); $key =~ tr/+/ /; $key =~ 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; $value =~s/<!--(.|\n)*-->//g; if ($formdata{$key}) { $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } } return %formdata; }
Hope this helps. -Ericopen (MAIL, "|/usr/bin/sendmail -t") or die "Error"; print MAIL "To: to@address.com \nFrom: from@address.com\n"; print MAIL "Subject: mail subject\n"; print MAIL "Add the contents here\n"; close (MAIL);
|
|---|