Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I've had puzzlingly little luck finding this on my own, so I resort to the monastery...

I can't seem to find much existing code to build up data structures (rather than flat lists) from passed (GET/POST) CGI data. I know nobody wants to be seen holding up anything from That Other 'P' Web Language as an exemplar, but... well, there it is.

For a trivial example, going from an HTML form with data like:

<input type="text" name="foo{bar}" value="barval"> <input type="text" name="foo{baz}" value="bazval">

into something in perl like:

$foo = get_param('foo'); # $foo = { bar => 'barval', baz => 'bazval' } and things roughly following its API provide ways (of greater or lesser convenience) of getting arrays of values. But finding something to build up hashes is an unrewarding search. The only thing I've managed to unearth is CGI::State, which is tightly tied to, is a little unsettling code- and known-limitation-wise, and has had 2 releases 3 days apart almost 10 years ago. Minor searching has turned up approximately 0 live uses of it. Doesn't encourage me to hitch my wagon to it...

Of course, I can just be the one that writes code to do it. I think highly enough of my ability for that. But I also think highly enough of Murphy that I'd rather not, and my Programmer's Laziness is in full-scale rebellion at the thought that this doesn't already exist. Surely I'm not actually just the second person in the last 15 years to want this?

In reply to Building data structures from CGI params by fullermd

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (2)
    As of 2018-05-22 01:10 GMT
    Find Nodes?
      Voting Booth?