--- Tee <[EMAIL PROTECTED]> wrote: > Can you do: my %foo = $cgi->param("foo") > > Else, how do you loop thru to put the array into %keys?
Sorry Tee, that won't work. Perl recognizes void, scalar, and list contexts. There is no "hash" context. If you have a hash on the left hand side of the equals sign (=), param() see you're in list context and return a list. One thing you can do (keeping in mind that $cgi->param returns the form param names and not the values): my %params = map { $_ => [$cgi->param($_)] } $cgi->param; With this, every key will represent one items on the form and every value will be an array ref containing the values for that form element. Written as a foreach loop, the above is the exact equivalent of this: my %params; foreach my $param ($cgi->param) { $params{$param} = $cgi->param($param); } Thus, if you have one value for the form element "username", you could access it like this: my $username = $form->{username}->[0]; If you have multiple values, you could access them like this: my @color = @{ $form->{color} }; Since most forms have one value per element, though, most people would choose something like this: my %form = map { $_ => $cgi->param($_) } $cgi->param; Of course, that loses data if any params have multiple values, but again, most forms are not like that. There are other ways to deal with this, but they are pretty safe and straightforward. Cheers, Ovid ===== If this message is a response to a question on a mailing list, please send follow up questions to the list. Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>