0
Server error!

The server encountered an internal error and was unable to complete your request.

Error message: 
Premature end of script headers: askName.pl

Heres my code...

#!/usr/bin/perl

#askName.plx

#use 5.006;
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI;

print "Content-type: text/html\n\n";

my $cgi = new CGI;

print"<html><head><title> Forms Intro! </title></head>"; print "<h1> Welcome, ",$cgi ->            
param('first'), " " , $cgi -> param('last'), "</h1>"; print"</html>";

I've tried formatting it like this also

print $cgi -> header();
print $cgi -> start_html("Welcome");
print "<h1> Welcome, ",cgi -> param('first'), " " , $cgi -> param('last');, "</h1>";
print $cgi -> end_html();

but it didn't work :/

RobEarl
  • 7,862
  • 6
  • 35
  • 50
Joe bob
  • 9
  • 4
  • 2
    From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): [How can I troubleshoot my Perl CGI script?](http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script) – daxim Jan 27 '12 at 23:10
  • This code runs on my sever without an error. What type of web server are you trying to run it on? My guess is it's a configuration issue. Do you have other perl scripts running on this web server? If so, do they run without a problem? If so, look at the differences between those other scripts and yours. If none of them run, you need to change some settings on your server. – AWT Jan 27 '12 at 23:13
  • Also, try running this from the command line and see what your output is. You should see your html headers and some basic html structure. If you don't get that, you might at least get a useful error message. – AWT Jan 27 '12 at 23:17
  • Though the advice is within the answer referred to by daxim, the reason your script isn't running should be stored in the error log for your web server (probably `/var/log/apache2/error.log` or whatever ErrorLog is set to in your `/etc/apache*/*.conf` file(s)) – unpythonic Jan 28 '12 at 09:03

2 Answers2

0

This is very often due to the Perl CGI not being set to executable. Basically the program isn't running at all for some reason.

Borodin
  • 126,100
  • 9
  • 70
  • 144
  • For anyone interested it was because I had a space before my code started...thanks for the suggestions though – Joe bob Feb 03 '12 at 21:37
0

May be your perl is not in the normal directory so try #!/usr/local/bin/perl on the top instead of #!/usr/bin/perl . This might work.

Mark Hall
  • 53,938
  • 9
  • 94
  • 111
Shamal
  • 1
  • 1