Actually you have just inspired my new one-line drop-in replacement for $cgi->Vars()...
$params = $cgi->Vars();
... becomes ...
$params = { map { $_ => ($cgi->param($_))[0] } $cgi->param };
... 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.
-- KILNA - pop music for cyborgs - http://www.kilna.com
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.