Kathryn Cassidy wrote:
> I've got a script which has to read in a variable number of
> parameters.
> Up 'till now, I've been using the CGI param() function to read in each
> variable one at a time. This won't work if I don't know how many
> variables there might be though, or what they'll be called.
>
> Is there any way to read all the variables that are passed to a cgi
> script into a hash using the variable name as the hash key?
Not directly, but using param() without an argument gives you a list
containing the names of parameters (which would become hash keys). So you
could simulate it with something like this:
%hash = map { $_, param($_) } param();
Note that this will mess up if you have parameters with more than one value
(e.g. a scrolling list with multiple select). In that case, you might be
better off with
%hash = map { $_, [ param($_) ] } param();
, though you will have to dereference each entry ($hash{'key'}->[0] instead
of $hash{'key'} for single-valued parameters; @{ $hash{'key'} } for
multiple-valued parameters).
Also, there's the import_names('namespace') function, which gives you lots
of variables in the 'namespace' namespace, e.g. $namespace::scalar,
@namespace::array.
Cheers,
Philip
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]