Code Comments
Programming Forum and web based access to our favorite programming groups.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)thanks!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; } } }
Post Follow-up to this message>>>>> "L" == Larry <dontmesswithme@got.it> writes: 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 -- Uri Guttman ------ uri@stemsystems.com -------- [url]http://www.stemsystems.com[/url ] --Perl Consulting, Stem Development, Systems Architecture, Design and Coding - Search or Offer Perl Jobs ---------------------------- [url]http://jobs.perl.org[/url ]
Post Follow-up to this messageIn article <x77jqiyijc.fsf@mail.sysarch.com>, Uri Guttman <uri@stemsystems.com> wrote: > > 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!
Post Follow-up to this messageLarry wrote: > (please don't reply telling me to use CGI.pm because i need to get this > code working) Use cgi.pm. It is the best way to get this code working.
Post Follow-up to this messageLarry <dontmesswithme@got.it> wrote: > (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. -- Tad McClellan SGML consulting tadmc@augustmail.com Perl programming Fort Worth, Texas
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.