For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > September 2004 > [newbie] decode the form information









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [newbie] decode the form information
Larry

2004-09-25, 3:59 am

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!
Uri Guttman

2004-09-25, 3:59 am

>>>>> "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 -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Larry

2004-09-25, 9:00 am

In 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!
Scott Bryce

2004-09-25, 3:56 pm

Larry 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.

Tad McClellan

2004-09-25, 3:56 pm

Larry <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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com