However I find that 9 times out of 10 you want the simpler hash, so you can collect the data twice in a slightly more complicated way something like this :-my $hash = {}; for ($cgi->param()) { push @{$hash->{$_}}, $cgi->param($_); }
You can then access most data with a simple $hash->{scalar}->{'whatever'} but for those cases when you cared about multiple entries you can do $hash->{list}->{'whatevers'}->1my $hash = {}; for ($cgi->param()) { push @{$hash->{list}->{$_}}, $cgi->param($_); $hash->{scalar}->{$_} = $hash->{list}->{$_}->[0]; }
I think the CGI module is fantastic, but I do find it much more convenient to have my data in a hash rather than have to call it from param() when I need it. For a CGI of any length then I'd certainly use one of another of the methods above.
In reply to RE: RE: Re: Easy way to run tests on many CGI params?
by ncw
in thread Easy way to run tests on many CGI params?
by meonkeys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |