Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

[newbie] decode the form information
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!

Report this thread to moderator Post Follow-up to this message
Old Post
Larry
09-25-04 08:59 AM


Re: [newbie] decode the form information
>>>>> "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
]

Report this thread to moderator Post Follow-up to this message
Old Post
Uri Guttman
09-25-04 08:59 AM


Re: [newbie] decode the form information
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!

Report this thread to moderator Post Follow-up to this message
Old Post
Larry
09-25-04 02:00 PM


Re: [newbie] decode the form information
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.


Report this thread to moderator Post Follow-up to this message
Old Post
Scott Bryce
09-25-04 08:56 PM


Re: [newbie] decode the form information
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

Report this thread to moderator Post Follow-up to this message
Old Post
Tad McClellan
09-25-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Forum Jump:
All times are GMT. The time now is 05:22 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.