I have looked on CPAN and here via Super Search and not found anything that fits the bill. Is there a CPAN module that given a content string (data sent via a form post) as a scalar variable will parse it and return a set of key, value pairs, properly unescaped? CGI.pm and Apache::Request.pm contain the code to do this, but is there anything standalone that doesn't require a full request object?

Example:
Given this input: a=7&b=1&text=Some+text+goes+here&required=Yes&submit=submit
Produce this data structure:

my $data = [ 'a' => 7, 'b' => 1, 'text' => 'Some text goes here', 'required' => 'Yes', 'submit' => 'submit', ];

The intended use is in a script that tests subroutines that are used inside of a mod_perl application. The subroutine under test expects pre-parsed post data in an array structure like that above. I'm using HTML::Form to extract and parse form data from an HTML page, then using it's $form->click method to click on various submit buttons on that page. $form->click returns an HTTP::Request object, from which I can extract the post data as a string (urlescaped and joined by ampersands), but I need to get that data properly parsed and unescaped to send it as input to the subroutine that I'm testing.


In reply to Parsing form post (content) by mp

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.