Parsing a Querystring With Perl (Page 1 of 3 )
Having trouble parsing a querystring with Perl? If so, then Jeff's step-by-step guide will save you headaches and have you up and running in no time!At first, parsing a CGI query sounds like a simple task. A query is just a list of key-value pairs, so a hash sounds like the right tool. But many CGI query parsers fail for anything other than what the specific query is they expect. What if it's a POST when you expected GET? What if the pairs are delimited by ; instead of &? What if the query is encoded via m/fd instead of a/xwfu? What if there's more than one value for a field? And what about file uploads, a topic I've not covered yet?
How quickly a simple function becomes complex. But if we break the cases down into simple procedures, we'll see it's not as bad as we thought.
Next: A Simple ISINDEX Query >>
More Perl Articles
More By Jeff Pinyan