Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
The original snippet does not work anymore, because of the deprecated 'prototyped' keyword. Below is an updated version, that can also be found online.
.sub hex2decimal .param string hex .local int result .local int position .local string digits .local int len result = 0 position = 0 digits = '0123456789ABCDEF' upcase hex len = length hex p_hex_loop: if position == len goto p_hex_over result *= 16 $S1 = hex[position] $I1 = index digits, $S1 result += $I1 inc position goto p_hex_loop p_hex_over: .return(result) .end .sub url_decode .param string theURL .local int position # + becomes space p_unesc_url_space: position = index theURL, '+' if position == -1 goto p_unesc_url_others_0 theURL[position] = ' ' goto p_unesc_url_space p_unesc_url_others_0: position = 0 p_unesc_url_others: position = index theURL, '%', position if position == -1 goto p_unesc_url_over $I1 = position + 1 $S1 = substr theURL, $I1, 2 $I1 = hex2decimal($S1) $S1 = chr $I1 theURL = substr position, 3, $S1 inc position goto p_unesc_url_others p_unesc_url_over: .return(theURL) .end .sub get_query_params .param string query .local pmc result result = new .Hash .local int start .local int end .local int len .local string key .local string value start = 0 parse: index end, query, '=', start if end == -1 goto ret len = end - start substr key, query, start, len key = url_decode(key) start = end + 1 index end, query, '&', start if end > -1 goto more_data substr value, query, start value = url_decode(value) result[key] = value goto ret more_data: len = end - start substr value, query, start, len value = url_decode(value) result[key] = value start = end + 1 goto parse ret: .return(result) .end

In reply to [Parrot] parsing CGI query string (update for Parrot 0.4) by Thilosophy
in thread [Parrot] parsing CGI query string by Thilosophy

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 musing on the Monastery: (15)
    As of 2014-10-30 14:04 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (208 votes), past polls