Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-06-2003, 11:16 AM   #1
Registered: Mar 2003
Location: Houston, TX
Distribution: RedHat 8.0
Posts: 79

Rep: Reputation: 15
Simple Perl prog. getting Error 500 message.

I was trying to just test a simple Perl/CGI script and I always seem to get this error even after I've tried chmod 775 and chmod 777.

This is my HTML...


<form action="/cgi-bin/post.cgi" method="POST">
Your Name: <input type="text" name="name">
Email Address: <input type="text" name="email">
Age: <input type="text" name="age">
Favorite Color: <input type="text" name="favorite_color">
<input type="submit" value="Send">
<input type="reset" value="Clear Form">


My Perl/CGI script...


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

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;
$FORM{$name} = $value;

print "<html><head><title>Form Output</title></head><body>";
print "<h2>Results from FORM post</h2>\n";

foreach $key (keys(%FORM)) {
print "$key = $FORM{$key}<br>";

print "</body></html>";

The Error message I get...

Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: post.cgi
If you think this is a server error, please contact the webmaster
Error 500
Sun 06 Jul 2003 08:18:16 AM EDT
Apache/2.0.40 (Red Hat Linux)
Old 07-06-2003, 11:25 AM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 67
Im not sure abotu:
foreach $key (keys(%FORM)) {

I would use:
foreach $key (keys %FORM) {

You also don't end with:

Try using my error log checking script to get more info:


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl-CGI 500 Error tzarcone Programming 1 07-01-2005 02:45 AM
PERL error 500 --- ronkymac Linux - Software 4 02-19-2005 07:05 AM
2 simple shell prog questions provkitir Linux - Software 3 11-23-2004 03:00 AM
Something wrong with this simple hello world prog mandrakeroot Programming 9 08-26-2003 05:24 PM
PERL error trying to run simple HTML page.... vous Programming 1 08-25-2003 09:01 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration