"David Hofmann" <[EMAIL PROTECTED]> writes:
> I have a form where several of the in hidden fields are named the same thing
> with diffrent values.
>
> With CGI.pm the I can use %in = $readquery->Vars; to put everything in a
> hash. Then I break the values base on \0.
>
> What the best way to do this with Apache::Request, and how does it handle
> multivalued parameters ?
You have quite a few options here:
1) Work with the Apache::Request::Table
$t = $req->param;
and use each(%$t), keys(%$t) and values(%$t) to iterate over the params
in document order (query_string args come first, then the POST
data in the order it was received). To get all entries for a
given parameter, you can use
@foo_vals = $t->get("foo");
You can also use $t->do(...) to iterate over the table entries with
a callback sub.
2) Think of the $req->param method as a "smart-hash", and use it in
the same way you'd use CGI::param (since that's the method
it is patterened after).
3) Try to stop using the $readquery->Vars API, since $req->param is
able to decode binary data with embedded '\0' values in them.
If you can't bring yourself to that, just write your own converter:
sub Vars {
my $req = shift;
map { $_ => join "\0", $req->param($_) } $req->param;
}
I hope this helps.
--
Joe Schaefer
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html