markhoy has asked for the wisdom of the Perl Monks concerning the following question:
so that I can use $uid = $request->{"uid}";# A simple HTTP request parser to emulate ASP request.xxx< # So you can do $request->{"clicked"} in place of Request("clicked") # Has problems with MIME or complex submits # sub getHTTPData { my $xx; my $buffer; my %vars; if($ENV{"REQUEST_METHOD"} eq "GET") { $buffer=$ENV{'QUERY_STRING'}; } else { read ( STDIN, $buffer, $ENV{"CONTENT_LENGTH"}); } foreach $pair (split(/&/, $buffer)) { $pair =~ tr/+//; ($name, $value) = split(/=/, $pair); $value =~ s/%(\w\w)/sprintf("%c", hex($1))/ge; # convert hex t +o ascii $value=~s/\+/ /g; $vars{$name}="$value"; } return \%vars; }
Fair enough. I also want to be able to access all the items submitted in a form. So I tried to use this bit of code as well:
That works fine. BUT if I use the following after the above code:use CGI ':standard'; print "Content-type: text/html\n\n"; print "<body>"; foreach my $name ( param() ) { my @values = param ($name); print "<p><b>Key:</b> $name <b>Value(s):</b> @values"; }
I get nada! Only one way will work (whichever is used first on the page)... am i asking to much to be able to do the equivalent of:$request = getHTTPData(); print "<br> fromtime is ". $request->{"fromTime"};
Ideally something in the sub getHTTPData() would probably be best. Any suggestions? (and I thought Lotus Script/ Domino was opaque...). Thanks,for each fld in request.form # do stuff with the name and value next
that I can then access later in the page?..;-)foreach fld in formdata{ make a variable named $fld have a value of $value }
Edit by tye: title, READMORE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why is this so hard?
by gjb (Vicar) on Dec 20, 2002 at 12:22 UTC | |
by hmerrill (Friar) on Dec 20, 2002 at 14:33 UTC | |
|
Re: why is this so hard?
by davorg (Chancellor) on Dec 20, 2002 at 13:23 UTC | |
|
Re: why is this so hard?
by Aristotle (Chancellor) on Dec 20, 2002 at 15:46 UTC | |
|
Re: why is this so hard?
by fruiture (Curate) on Dec 20, 2002 at 13:23 UTC | |
|
Re: why is this so hard?
by diotalevi (Canon) on Dec 20, 2002 at 15:01 UTC |