Saturday, March 16, 2002, 12:42:40 AM, Tiller, Jason wrote:
> my %params;

> $params{$_} = param($_) foreach param();

> If I understand your code correctly, param() returns a list of all the
> possible keys, right?  If so, then the above code should work.  You refer to
> the parameters as $param{name} instead of just $name.

Just FYI, CGI.pm has a method to do that for you:

  my $q = new CGI;
  %params = $q->Vars;

>From the CGI.pm docs:

  Many people want to fetch the entire parameter list as a
  hash in which the keys are the names of the CGI
  parameters, and the values are the parameters' values. The
  Vars() method does this. Called in a scalar context, it
  returns the parameter list as a tied hash reference.
  Changing a key changes the value of the parameter in the
  underlying CGI parameter list. Called in a list context,
  it returns the parameter list as an ordinary hash. This
  allows you to read the contents of the parameter list, but
  not to change it.

  When using this, the thing you must watch out for are
  multivalued CGI parameters. Because a hash cannot
  distinguish between scalar and list context, multivalued
  parameters will be returned as a packed string, separated
  by the "\0" (null) character. You must split this packed
  string in order to get at the individual values. This is
  the convention introduced long ago by Steve Brenner in his
  cgi-lib.pl module for Perl version 4.


-- 
Best Regards,
Daniel                   [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to