You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dennis Stout <st...@stout.dyndns.org> on 2003/07/10 22:52:20 UTC
Re: select multiple
> Because there is no way to create a delimiter that the potential data
doesn't contain, the browser doesn't have the option to choose an arbitrary
delimiter like a comma, or the like. So (though I can't speak for all
browsers most will do the same) each value is passed with the same key, so
your string ends up like:
>
> ?queue=lvl1&queue=lvl2&queue=admin&queue=sysad&foo=bar
>
> This punts the problem to the server side (or whatever does the query string
parsing) so there are multiple ways to handle it, build a complex data
structure that stores an array reference for any multi-valued keys, store the
keys with some known delimiter (aka cgi-lib.pl used to use the null character
\0). So it depends on your request parser, some provide multiple manners (I
think the standard CGI does). Have a look at the respective docs for how your
parser handles it, unless you are writing a parser...but then why do that with
so many good freely available ones?
Interesting.
So in mod_perl, I would use $r->args{__what__} to get to it? Heh.
I'll email the mod_perl list..
Dennis
Re: select multiple
Posted by Dennis Stout <st...@stout.dyndns.org>.
> >mod_perl and the methods available in the apache request object shuold
beable
> >to replace CGI.pm entirely, especially when you have a highly customized
> >RequestHandler :/
> >
> >Guess I'll see what happens, since I need cookie headers to work AND now
> >multiple values for one param.
>
> Have you looked at Apache::Request?
Reading documentation.. and it looks like $r->param is what I need :) Thanks!
--- perldoc Apache::Request ---
param
Get or set request parameters (using case-insensitive
keys) by mimicing the OO interface of "CGI::param".
Unlike the CGI.pm version, Apache::Request's param
method is very fast- it's now quicker than even
mod_perl's native Apache->args method. However,
CGI.pm's "-attr => $val" type arguments are not sup-
ported.
# similar to CGI.pm
my $value = $apr->param('foo');
my @values = $apr->param('foo');
my @params = $apr->param;
# the following differ slightly from CGI.pm
# assigns multiple values to 'foo'
$apr->param('foo' => [qw(one two three)]);
# returns ref to underlying apache table object
my $table = $apr->param; # identical to $apr->parms - see below
parms
Get or set the underlying apache parameter table of
the Apache::Request object. When invoked without
arguments, "parms" returns a reference to an
Apache::Table object that is tied to the
Apache::Request object's parameter table. If called
with an Apache::Table reference as as argument, the
Apache::Request object's parameter table is replaced
by the argument's table.
# $apache_table references an Apache::Table object
$apr->parms($apache_table); # sets $apr's parameter table
# returns ref to Apache::Table object provided by $apache_table
my $table = $apr->parms;
Re: select multiple
Posted by Todd Finney <tf...@boygenius.com>.
At 05:58 PM 7/10/03 -0800, Dennis Stout wrote:
>mod_perl and the methods available in the apache request object shuold beable
>to replace CGI.pm entirely, especially when you have a highly customized
>RequestHandler :/
>
>Guess I'll see what happens, since I need cookie headers to work AND now
>multiple values for one param.
Have you looked at Apache::Request?
Re: select multiple
Posted by Wiggins d'Anconia <wi...@danconia.org>.
Dennis Stout wrote:
> ARHG.
>
> I want to stay as far away from use CGI; as possible =/
>
> *sigh*
>
> mod_perl and the methods available in the apache request object shuold beable
> to replace CGI.pm entirely, especially when you have a highly customized
> RequestHandler :/
>
> Guess I'll see what happens, since I need cookie headers to work AND now
> multiple values for one param.
>
Probably best to try and see. Setup a simple handler that calls $r->args
in list context and then step through the elements and see how they
are arranged. I poked around in the 1.0 docs but wasn't able to come up
with anything concrete, you might also mention which version of mod_perl
you are dealing with....
http://danconia.org
Re: select multiple
Posted by Dennis Stout <st...@stout.dyndns.org>.
ARHG.
I want to stay as far away from use CGI; as possible =/
*sigh*
mod_perl and the methods available in the apache request object shuold beable
to replace CGI.pm entirely, especially when you have a highly customized
RequestHandler :/
Guess I'll see what happens, since I need cookie headers to work AND now
multiple values for one param.
S.T.O.U.T. = Synthetic Technician Optimized for Ultimate Troublshooting
----- Original Message -----
From: "Chris Faust" <cf...@doyougot.com>
To: "Dennis Stout" <st...@stout.dyndns.org>; <wi...@danconia.org>;
<be...@perl.org>; <mo...@perl.apache.org>
Sent: Thursday, July 10, 2003 16 30
Subject: Re: select multiple
> CGI.pm does the trick for me, the multi values are seperated by \0
>
> < select name="yadda" multi>
> <DEFANGED_option>yadda1
> <DEFANGED_option>yadda2
> <DEFANGED_option>yadda3
> ....
> </DEFANGED_select>
>
> my $CGI = new CGI();
> %form_data = $CGI->Vars;
>
> @options = split("\0",$form_data{'yadda'});
>
> $options[0] = yadda1, $options[1] = yadda2 etc .
>
> Not usable live code obviously, but you should see the idea...
>
> -Chris
> ----- Original Message -----
> From: "Dennis Stout" <st...@stout.dyndns.org>
> To: <wi...@danconia.org>; <be...@perl.org>;
> <mo...@perl.apache.org>
> Sent: Thursday, July 10, 2003 4:52 PM
> Subject: Re: select multiple
>
>
> >
> > Interesting.
> >
> > So in mod_perl, I would use $r->args{__what__} to get to it? Heh.
> >
> > I'll email the mod_perl list..
> >
> > Dennis
> >
>
>
Re: select multiple
Posted by Chris Faust <cf...@doyougot.com>.
CGI.pm does the trick for me, the multi values are seperated by \0
< select name="yadda" multi>
<option>yadda1
<option>yadda2
<option>yadda3
....
</select>
my $CGI = new CGI();
%form_data = $CGI->Vars;
@options = split("\0",$form_data{'yadda'});
$options[0] = yadda1, $options[1] = yadda2 etc .
Not usable live code obviously, but you should see the idea...
-Chris
----- Original Message -----
From: "Dennis Stout" <st...@stout.dyndns.org>
To: <wi...@danconia.org>; <be...@perl.org>;
<mo...@perl.apache.org>
Sent: Thursday, July 10, 2003 4:52 PM
Subject: Re: select multiple
>
> Interesting.
>
> So in mod_perl, I would use $r->args{__what__} to get to it? Heh.
>
> I'll email the mod_perl list..
>
> Dennis
>