You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tatsuhiko Miyagawa <mi...@edge.co.jp> on 2001/10/31 18:42:16 UTC

inconsistency between CGI.pm and Apache::Request

There is some inconsistency between CGI.pm and Apache::Request's
param() method, especially in handling of multivalued parameter.

  $q = CGI->new;
  $q->param(foo => qw(a b c));
  @foo = $q->param('foo');         # ('a', 'b', 'c')
  $q->param(bar => [ qw(a b c) ]);
  @bar = $q->param('bar');         # (['a', 'b', 'c'])

  $r = Apache::Request->new(Apache->request);
  $r->param(foo => qw(a b c));     # die with an error
  $r->param(bar => [ qw(a b c) ]);
  @bar = $r->param('bar');         # ('a', 'b', 'c')

Am I the only one who wants consistency between the two?

CGI.pm		2.78
Apache::Request	0.33


--
Tatsuhiko Miyagawa <mi...@bulknews.net>


Re: inconsistency between CGI.pm and Apache::Request

Posted by Tatsuhiko Miyagawa <mi...@edge.co.jp>.
On Wed, 31 Oct 2001 13:32:23 -0500
Robert Landrum <rl...@capitoladvantage.com> wrote:

> Try
> $r->param('foo',qw(a b c));

It dies with:

  Usage: Apache::Request::param(req, key=NULL, sv=Nullsv) at ...

(version is 0.33)

Thanks.

--
Tatsuhiko Miyagawa <mi...@bulknews.net>


Re: inconsistency between CGI.pm and Apache::Request

Posted by Robert Landrum <rl...@capitoladvantage.com>.
>There is some inconsistency between CGI.pm and Apache::Request's
>param() method, especially in handling of multivalued parameter.
>
>  $q = CGI->new;
>  $q->param(foo => qw(a b c));
>  @foo = $q->param('foo');         # ('a', 'b', 'c')
>  $q->param(bar => [ qw(a b c) ]);
>  @bar = $q->param('bar');         # (['a', 'b', 'c'])
>
>  $r = Apache::Request->new(Apache->request);
>  $r->param(foo => qw(a b c));     # die with an error
>  $r->param(bar => [ qw(a b c) ]);
>  @bar = $r->param('bar');         # ('a', 'b', 'c')

Doesn't this have something to do with the way your shorthanding 
Apache::Request?

Try
$r->param('foo',qw(a b c));

It might work... I remember running into this several years ago, and 
never mentioned it.


>Am I the only one who wants consistency between the two?

No.  It's my opinion that CGI.pm is wrong.  Never would an input 
value come out as an arrayref.  And never would you want to store an 
arrayref in something that might be used to generate hidden inputs.

Lincoln can argue with me.

Rob


--
"Only two things are infinite: The universe, and human stupidity. And I'm not
sure about the former." --Albert Einstein