in reply to (Ovid) Re: Best way to parse CGI params
in thread Best way to parse CGI params
... becomes ...$params = $cgi->Vars();
... or if you want a straight hash instead of the hashref that Vars() gives you, you can ...$params = { map { $_ => ($cgi->param($_))[0] } $cgi->param };
This way seems DWIMmer since it returns what I expect most people *think* $cgi->Vars() does, which is a hash with a single scalar as the value, which ignores multiple instances of cgi params. I can't think of any time where I've actually needed multiple instances of the same name CGI parameter back (Then again, I avoid multi-select boxes ;). If I do need multiple values, you can still get at them via $cgi->param('foo'), or Ovid's method. Since mine doesn't require dereferencing the arrayref, it may be a little more convenient for newbies.%params = map { $_ => ($cgi->param($_))[0] } $cgi->param;
|
|---|