|P is for Practical|
Building data structures from CGI paramsby fullermd (Priest)
|on Nov 21, 2010 at 09:44 UTC||Need Help??|
fullermd has asked for the wisdom of the Perl Monks concerning the following question:
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:
into something in perl like:
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?