This appears to be decoding urlencoded characters like %20 to their ASCII equivalents. What's happening is:<bl>
  • The two-character hex pairs are being detected and saved by the parentheses in ths s/// command
  • For each two-character hex value, the right side is computed as pack("C",hex($1)) which calls hex() to convert, for instance, "2f" into the number 47. Then pack() is called to take the single number 47 and convert it into the character '/'. This character becomes the value that is substituted for the entire "%2f" in the original string.
  • </bl>

    I wouldn't be surprised, though, to find that the CGI module would do this for you. However, since I don't use it, I can't tell you how.

    update: as others have said, you shouldn't be doing this by hand; use CGI. Also, changed ANSI to ASCII.


    In reply to Re: Enlightment for a little french by bikeNomad
    in thread Please explain this (CGI) parsing routine by Prosélyte

    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.