Gossamer Forum
Skip to Content



Home : General : Perl Programming :

cannot use param and other stuff - Internal Server Error

Quote Reply
cannot use param and other stuff - Internal Server Error
I got a server here at a company. I can run the following codes in any other server, but not in this particular one.
Anyone know how to configure the server to let it work?

500 Internal Server Error

If I marked out the param lines, it works fine.

Code:


#!/usr/bin/perl -w
use CGI qw/:standard/;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
print header,
start_html('A Simple Example'),
start_form,
p('Your name?'),
textfield('name'),
p,
submit,
end_form,
hr;
if (param()) {
print "Your name is", param('name'), hr;
}
print end_html;
Quote Reply
Re: [junshi] cannot use param and other stuff - Internal Server Error In reply to
Hi,

Erm, what exactly is:

Code:
if (param()) {
..mean't to be doing?

Looks like you need:

Code:
if (param('name')) {

Also,to make your scripts easier (in terms of including extra modules) - I would tend to go for something more like this:

Code:
#!/usr/bin/perl -w
use CGI qw/:standard/;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
my $cgi = new CGI;
print $cgi->header,
$cgi->start_html('A Simple Example');
$cgi->start_form,
$cgi->p('Your name?'),
$cgi->textfield('name'),
$cgi->p,
$cgi->submit,
$cgi->end_form,
$cgi->hr;

if (param('name')) {
print "Your name is", param('name');
$cgi->hr;
}

print $cgi->end_html;

(or at least, something like that Tongue - didn't test it)

Cheers

Andy (mod)
andy@ultranerds.com


Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Custom Toolbar for IE and Firefox! - Compare our different Plugin packages *new*
Free CSS Templates
Quote Reply
Re: [Andy] cannot use param and other stuff - Internal Server Error In reply to
Code:
if (param()) {


...is perfectly acceptable, although param('name') is more logical.

Last edited by:

Wychwood: Jun 24, 2008, 4:43 PM