perlfaq nodetype
faq_monk
<P>
Here's an example of decoding:
<P>
<PRE> $string = "<A HREF="http://altavista.digital.com/cgi-bin/query?pg=q&">http://altavista.digital.com/cgi-bin/query?pg=q&</A>;what=news&fmt=.&q=%2Bcgi-bin+%2Bperl.exe";
$string =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge;
</PRE>
<P>
Encoding is a bit harder, because you can't just blindly change all the
non-alphanumunder character (<CODE>\W</CODE>) into their hex escapes. It's important that characters with special
meaning like <CODE>/</CODE> and <CODE>?</CODE>
<EM>not</EM> be translated. Probably the easiest way to get this right is to avoid reinventing the wheel and just use the URI::Escape module, which is part of the libwww-perl package
<FONT SIZE=-1>(LWP)</FONT> available from
<FONT SIZE=-1>CPAN.</FONT>
<P>