This checks for zero or more of any character followed by 2 occurances of either ?:~.+
The (?: ... ) construction is 'pure grouping.' So (?:~.+){2} matches, but does not assign to a variable, a tilde ~ followed by one or more chars twice.... basically checking for 2 tildes. Somebody else could write this more elegantly, I'm sure.

Here's an example querystring. I'll use the names that shotgunefx suggested.

?item~1~name=boobtube&item~1~qty=1&item~1~code=mysqlpk&item~2~name=loo +sifer&item~2~qty=1&item~2~code=666&ship~firstname=Han ...
Since now we're dealing with fields with 2 and 3 ids, we need to adjust the code some.
# Always use warnings; use strict; use CGI; my $q = CGI::new; my %lineitem; my %ship; # process params # for my $param ( $q->param ) { my @id = split(/~/,$param); # a SWITCH would work nicely, but I'll try # not to confuse the example if ( $id[0] eq 'item' ) { $lineitem{$id[1]}{$id[2]} = $q->param($param); } if ( $id[0] eq 'ship' ) { $ship{$id[1]} = $q->param($param); } } # process lineitems # print "Please confirm order of<br/> "; for my $item ( keys %lineitem ) { print $lineitem{$item}{qty}, $lineitem{$item}{name}; print "<br/>"; } print "<br/>being shipped to $ship{firstname}<br/>";
Is this a better example?

(Edit: minor spelling and grammer fixes)
(Edit: replaced my ($id1,$id2,$id3) = with my @id =)


In reply to Re3: Handling Dynamic URL Parameters by Solo
in thread Handling Dynamic URL Parameters by the_Don

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.