On Wed, 6 Jul 2005, Ron Smith wrote:
I'm getting an error when I submit the following html form to a CGI
script.
Let's focus on the script, not the HTML.
Once you've verified that the script works, at least on a basic level --
i.e. you can go to http://your-site/cgi-bin/your-script.cgi and get back
a non-error response -- *then* you can start thinking about the HTML.
#!/www/perl/bin/perl -wT
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print header;
print CORE::dump(); # <===== This line was originaly: print dump();
Okay, hold that thought...
---------snip-3-From the browser---------------
Internal Server Error
This continues to be useless. It's a generic error response from the web
server; it indicates nothing about what the actual problem was. That
said, with CGI::Carp's fatalsToBrowser, you should be getting useful
diagnostics in the web server response. Maybe it's hidden in a comment
or something, I don't know. In any case, the response you pasted doesn't
have any useful information in it, just as it didn't when you pasted it
to the list a few days ago :-)
--------------snip-4-From the error log--------------
[Wed Jul 06 18:23:56 2005] [error] [client 127.0.0.1]
Premature end of script headers: form4-21.cgi,
referer: http://localhost/form4-21.html
Okay, now we're getting somewhere.
"Premature end of script headers" is generally a tell-tale sign that the
CGI script never sent back the mandatory content-type declaration. I'm
not clear why this isn't working, as the `print header;` line you have
should do this, but in any case you can ignore CGI.pm for a moment and
just put the needed line in directly, like so:
#!/www/perl/bin/perl -wT
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/plain\n\n";
print "Okay, at least this worked.\n";
If the code above works, then you can amend it to use your CORE line:
#!/www/perl/bin/perl -wT
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/plain\n\n";
print CORE::dump();
Now then, why on earth are you trying to dump core?
If you just want to output the environment, this is a clumsy way to do
it. Something like this would work just fine:
#!/www/perl/bin/perl -wT
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/plain\n\n";
print "Environment variable dump:\n";
foreach $key ( sort keys %ENV ) {
print "$key: $ENV{$key}\n";
}
That should work, and as it isn't dumping core, it might even behave :-)
--
Chris Devers
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>