Pearl Script Help

#!/usr/bin/perl


$basedir = "/home/MYUSERID/public_html/ordered_files";
$allowall = "yes";
$theext = ".gif";

use CGI;
 
$onnum = 1;

while ($onnum != 11) {
my $req = new CGI; 
my $file = $req->param("FILE$onnum"); 
if ($file ne "") {
my $fileName = $file; 
$fileName =~ s!^.*(\\|\/)!!; 
$newmain = $fileName;
if ($allowall ne "yes") {
if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){
$filenotgood = "yes";
}
}
if ($filenotgood ne "yes") { 
open (OUTFILE, ">$basedir/$fileName"); 
print "$basedir/$fileName<br>";
while (my $bytesread = read($file, my $buffer, 1024)) { 
print OUTFILE $buffer; 
} 
close (OUTFILE); 
}
}
$onnum++;
}


my $sendmail = "/usr/sbin/sendmail";

# A text file containing a list of valid email recipients and the web pages to 
# which the user should be redirected after email is sent to each, on 
# alternating lines.  This allows one copy of the script to serve multiple 
# purposes without the risk that the script will be abused to send spam.
# YOU MUST CREATE SUCH A TEXT FILE AND CHANGE THE NEXT LINE TO ITS
# LOCATION ON THE SERVER.

my $emailConfPath = "http://www.MEWEBSITE.com/emailman/email.conf";

# Parse any submitted form fields and return an object we can use
# to retrieve them
my $query = new CGI;

my $project = &clean($query->param('project'));
my $name = &clean($query->param('name'));
my $number = &clean($query->param('number'));
my $address = &clean($query->param('address'));
my $address2 = &clean($query->param('address2'));
my $citystate = &clean($query->param('citystate'));
my $sizing = &clean($query->param('sizing'));
my $comments = &clean($query->param('comments'));
my $subject = &clean($query->param('subject'));
my $file1 = &clean($query->param('file1'));
my $file2 = &clean($query->param('file2'));
my $text = &clean($query->param('text'));
my $font = &clean($query->param('font'));
my $dropshadow = &clean($query->param('dropshadow'));
my $textcolor = &clean($query->param('textcolor'));
my $shadowcolor = &clean($query->param('shadowcolor'));


#Note: subject is not mandatory, but you can easily change that
if (($project eq "") || (($name eq "") || ($number eq "") || ($address eq "") || ($citystate eq "") || ($sizing eq ""))
{
	&error("Requist Denied",
		"You must fill out all of the required fields." .
		"Please Try Again.");
}

if (!open(IN, "$emailConfPath")) {
	&error("Configuration Error",
		"The Configuration file is missing or corrupt" .
		"please repair the file.");
	my $ok = 0;
	while (1) {
		my $recipientc = <IN>;
		if ($recipientc eq "") {
			last;
		}
		my $returnpage = <IN>;
		if ($returnpage eq "") {
			last;
		}
		if ($recipientc eq $recipient) {
			$ok = 1;
			last;
		}
	}
	close(IN);
	if (!$ok) {
		&error("Email Rejected",
			"You are unable to submit a file at this time try e-mailing this form to :" .
			"user@MEWEBSITE.com to get your order in." .
			"You also may note that there is a problem with this form on the site.");
	}
	# Open a pipe to the sendmail program
	open(OUT, "|$sendmail -t");
	print OUT <<EOM
To: $recipient
Subject: $subject
Project Name:       $project
Customers Name:     $name 
Customers Phone:    $number 
Address:            $address 
                    $address2 
City/State/Zip:     $citystate 
Sizing:             $sizing
Files:              $file1
                    $file2
Lettering Text:     $text
Font for Lettering: $font
Drop Shadow:        $dropshadow
Text Color:         $textcolor
Shadow Color:       $shadowcolor
Additional Notes:   $comments

EOM
;
	close(OUT);
	# Now redirect to the appropriate "landing" page for this recipient.
	print $query->redirect($returnPage);
}

sub clean
{

	my $s = shift @_;
	$s =~ s/^\s+//;
	$s =~ s/\s+$//;
	return $s;
}

sub error
{
	my($title, $content) = @_;
	print $query->header;
	print <<EOM
<html>
<head>
<title>$title</title>
</head>
<body>
<h1 align="center">$title</h1>
<p>
$content
</p>
EOM
;
	exit 0;
}


It might help if you were to indicate what help you want.

Also it would be best to enclose your script in code tags so thatformatting is preserved, it makes it much easier to read.

Okay that is the code what it is supposed to do is work with a form to upload
files and email the form info.

Can someone take a look and tell me where the problem is

The error is 500
Unexpected server error.
It doesn't give any details.

Sorry new here I edited and added the details after.
My srver is giving me a very plain error message and doesn't give a line number either...

Can you access the server log? I mean the Apache error log? If you are on a paid host, you can mostly access it (via CPanel, Plesk or something like that), or maybe you can have access to the physical log too (for dedicated server). Most of the time the exact perl error should be there with the line number with some context information.

The 500 internal server error message is not the perl error message that should give. Unless you can give this error, it is impossible to tell what went wrong.

Premature end of script headers: /home/MEUSERID/public_html/cgi-bin/order.cgi Execution of order.cgi aborted due to compilation errors. {" syntax error at order.cgi line 71, near ")

Okay it seems to me I am having a problem with the ending of the script before the files are finished uploading. I thinks this is because I combined 2 old scipts I wrote and edited for the needs of this site so can someone tell me where I need to put the
exit0;
command at at I think that should solve the problem....
Or at least the one I know about now.

Thank You
Nikah

Usually you put only an exit() function for abnormal exits. In your script the abnormal exit is at &error(), which you put in an exit() already.

You have removed the extra left parenthesis, did you?

if (($project eq "") || (($name eq "") || ($number eq "") || ($address eq "") || ($citystate eq "") || ($sizing eq ""))

I didn't see that and thanks I think that is the problem as I am no expert in CGI but in the editing I did add that extra parethesis by mistake.... will try that and get back to you. Also is there a good notepad with line numbering that you can refer me to that is free so I can locate where the errors are more easily so I don't have to ask stupid questions like this as often now that I gained access to my error logs.

On XP at least, in notepad, click on view and turn on staus bar. A status bar will appear at the bottom showing the line and column of the cursor.