Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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' }

CGI.pm 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 CGI.pm, 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

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (9)
    As of 2014-10-01 01:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (386 votes), past polls