Here's an easy way to deal with that.

my %post_data = map { $_ => param( $_ ) } param; my %url_data = map { $_ => url_param( $_) } url_param; my %data = merge( \%post_data, \%url_data ); sub merge { my %merged; for (@_) { while (my ($key, $value) = each %$_) { push @{$merged{$key}}, $value; } } %merged; }

%data will then contain all key value pairs. Note, this is not the best way to do this, but it's fairly easy to understand (though you'll want to read about map and references to grok all of it). Further, all values will be list references with this method, so accessing a single 'color' parameter would be $data{'color'}->[0]. The other option is to leave the two hashes separate and use them as necessary, but then you again have two data structures for one type of data. Yuck.

Oh, and the &merge is from MeowChow :)

As a side note: you shouldn't be mixing GET and POST. They have different uses. GET is for getting info and POST is for posting info. GET requests are often cached and POST requests shouldn't be. Mixing these methods could have undesireable side-effects.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid - grabs params separately and merge them)Re(5): use CGI by Ovid
in thread making a hash from cgi parameters by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.