I am a perl/cgi beginner and I have written a Perl script to email info entered into a form. I getting an error message which just say that there may be a scripting error. I am not sure what it is. Below is the script, please help.
#!/usr/bin/perl
%postInputs = readPostInput();
$dateCommand = "date";
$time = `$dateCommand`;
open (MAIL, "|/usr/sbin/sendmail -t" || return 0;
select (MAIL);
print << "EOF";
To: sam\ @pterosaurtechnology.co.uk
From: $postInputs{ 'email'}
Subject: Questionaire Form
$time
Name: $postInputs{ 'name'}
Address1: $postInputs{ 'address1'}
Address2: $postInputs{ 'address2'}
Address3: $postInputs{ 'address3'}
Address4: $postInputs{ 'address4'}
DOB: $postInputs{ 'dob'}
Tel: $postInputs{ 'phone'}
Fax: $postInputs{ 'fax'}
Email: $postInputs{ 'email'}
Marital Status: $postInputs{ 'marital'}
No. of Children: $postInputs{ 'children'}
No of Dependants: $postInputs{ 'depend'}
Details of Dependants: $postInputs{ 'dependDetails'}
Close Relative in UK: $postInputs{ 'inUK'}
Close Relatives Overseas: $postInputs{ 'overseas'}
Qualifications: $postInputs{ 'qualifications'}
Present Employment: $postInputs{ 'employ'}
Present Salary: $postInputs{ 'salary'}
Spouses Employment: $postInputs{ 'spouseEmploy'}
Spouses Salary: $postInputs{ 'spouseSalary'}
Ancestry: $postInputs{ 'ancestry'}
Intentions: $postInputs{ 'intentions'}
Details: $postInputs{ 'previous'}
EOF
close(MAIL);
select (STDOUT);
printThankYou();
sub readPostInput(){
my (%searchField, $buffer, $pair, @pairs);
if ($ENV{ 'REQUEST_METHOD'} eq 'POST'){
read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$searchField { $name} = $value;
}
} return (%searchField);
}
sub printThankYou(){
print << "EOF";
Content-Type: text/html
<head>
<title>Thank You</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#F7F7F7">
<div align="center">
<h2>THANK YOU</h2>
<h5>THANK YOU $postInputs{ 'name'} FOR SUBMITTING YOUR REQUEST FOR
INFORMATION.<br>
WE WILL GET BACK TO YOU AS SOON AS POSSIBLE.</h5>
</div>
</body>
</html>
EOF
}
#!/usr/bin/perl
%postInputs = readPostInput();
$dateCommand = "date";
$time = `$dateCommand`;
open (MAIL, "|/usr/sbin/sendmail -t" || return 0;
select (MAIL);
print << "EOF";
To: sam\ @pterosaurtechnology.co.uk
From: $postInputs{ 'email'}
Subject: Questionaire Form
$time
Name: $postInputs{ 'name'}
Address1: $postInputs{ 'address1'}
Address2: $postInputs{ 'address2'}
Address3: $postInputs{ 'address3'}
Address4: $postInputs{ 'address4'}
DOB: $postInputs{ 'dob'}
Tel: $postInputs{ 'phone'}
Fax: $postInputs{ 'fax'}
Email: $postInputs{ 'email'}
Marital Status: $postInputs{ 'marital'}
No. of Children: $postInputs{ 'children'}
No of Dependants: $postInputs{ 'depend'}
Details of Dependants: $postInputs{ 'dependDetails'}
Close Relative in UK: $postInputs{ 'inUK'}
Close Relatives Overseas: $postInputs{ 'overseas'}
Qualifications: $postInputs{ 'qualifications'}
Present Employment: $postInputs{ 'employ'}
Present Salary: $postInputs{ 'salary'}
Spouses Employment: $postInputs{ 'spouseEmploy'}
Spouses Salary: $postInputs{ 'spouseSalary'}
Ancestry: $postInputs{ 'ancestry'}
Intentions: $postInputs{ 'intentions'}
Details: $postInputs{ 'previous'}
EOF
close(MAIL);
select (STDOUT);
printThankYou();
sub readPostInput(){
my (%searchField, $buffer, $pair, @pairs);
if ($ENV{ 'REQUEST_METHOD'} eq 'POST'){
read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$searchField { $name} = $value;
}
} return (%searchField);
}
sub printThankYou(){
print << "EOF";
Content-Type: text/html
<head>
<title>Thank You</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#F7F7F7">
<div align="center">
<h2>THANK YOU</h2>
<h5>THANK YOU $postInputs{ 'name'} FOR SUBMITTING YOUR REQUEST FOR
INFORMATION.<br>
WE WILL GET BACK TO YOU AS SOON AS POSSIBLE.</h5>
</div>
</body>
</html>
EOF
}