in reply to Tracking down the source of '500 server' errors

If your script returns HTML, you need to have a line:
print "Content-type: text/html\n\n";
It looks like that may be another problem.
(If you  use CGI qw/:standard/; then you can get this with  print header('text/html');)
chas