[newbie] decode the form information

L

Larry

Hi folks!

I've a couple of questions i wanna ask you:

1) I've been using the code above to decode the form information.
Unfortunately if I call "use strict" at the top of the script it all
wretchedly fail and I get a 500 error from the server...

2) How would you go about setting a postmax value in the
"parse_form_data" of the script? (say,something like $CGI::pOST_MAX=1024
* 150;)

(please don't reply telling me to use CGI.pm because i need to get this
code working)

Code:
#!/usr/bin/perl

&parse_form_data (*simple_form);

my $user = $simple_form{'user'};

print "Content-type: text/plain", "\n\n";
$user = $simple_form{'user'};
if ($user) {
print "Nice to meet you ", $simple_form{'user'}, ".", "\n";
print "Please visit this Web server again!", "\n";
} else {
print "You did not enter a name. Are you shy?", "\n";
print "But, you are welcome to visit this Web server again!", "\n";
}
exit(0);

sub parse_form_data
{

local (*FORM_DATA) = @_;
local ( $request_method, $query_string, @key_value_pairs,
$key_value, $key, $value);

$request_method = $ENV{'REQUEST_METHOD'};
if ($request_method eq "GET") {
$query_string = $ENV{'QUERY_STRING'};
} elsif ($request_method eq "POST") {
read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
} else {
&return_error (500, "Server Error",
"Server uses unsupported method");
}

@key_value_pairs = split (/&/, $query_string);
foreach $key_value (@key_value_pairs) {
($key, $value) = split (/=/, $key_value);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;

if (defined($FORM_DATA{$key})) {
$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
} else {
$FORM_DATA{$key} = $value;
}
}
}

thanks!
 
U

Uri Guttman

L> 1) I've been using the code above to decode the form information.
L> Unfortunately if I call "use strict" at the top of the script it all
L> wretchedly fail and I get a 500 error from the server...

L> 2) How would you go about setting a postmax value in the
L> "parse_form_data" of the script? (say,something like $CGI::pOST_MAX=1024
L> * 150;)

L> (please don't reply telling me to use CGI.pm because i need to get this
L> code working)

use CGI.pm

there is no worldy reason you must get this code to work that would
cause you to not want to use cgi.pm. the code shown is pure perl4,
highly broken and about 10 years out of date.

now it is your turn to whine that you said you can't use cgi.pm. and i
will just reply that you don't know how to fix this code and cgi.pm
already fixes it. then you will say you have to run this under
perl4. and i will say then upgrade. then you will say this is all your
cheapo web hoster runs. i will reply then get a modern web host. you
will then flame about why doesn't anyone answer the original
question. hopefully some of the other cabal^Wregulars chime in about
using cgi.pm and wondering about your iq as compared to W.

so instead of having that long, repetative, deja vu^Wgoogle group
archived flame fest, just shut up and use cgi.pm. i am just trying to
save your skin and lower usenet bandwidth use at the same time.

i used PSI::ESP to prognosticate how this thread will devolve. just
another great module found on cpan (comprehensive psychic archive
network).

uri
 
L

Larry

so instead of having that long, repetative, deja vu^Wgoogle group
archived flame fest, just shut up and use cgi.pm. i am just trying to
save your skin and lower usenet bandwidth use at the same time.

hey man...you are right!
 
T

Tad McClellan

Larry said:
(please don't reply telling me to use CGI.pm because i need to get this
code working)


It will take *less* time to get CGI.pm working than to repair
your broken code.

If you a truly in a hurry, then give up on what you have and
replace it with a proper module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top