in reply to Please explain this (CGI) parsing routine

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.

    Replies are listed 'Best First'.
    (ar0n) Re (2): Enlightment for a little french
    by ar0n (Priest) on Jun 16, 2001 at 19:52 UTC
      Simply use param() instead of accessing a hash:
      use CGI ':standard'; my $val = param('foo');


      ar0n ]