As they already said, there's a Module to do this ... or several (TMTOWTDI) ...
but there's also a really cute expression that's worth grokking-in-fullness, even if you should use the module instead, since it's a lovely example of s///g and s///e together.
From Effective Perl Programming (Hall with Schwartz, 0-201-41975-0 not linked to Fatbrain, please support your local meatspace bookstore),
$_ = "a%5eb";
s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
which also says only one paragraph later
use URI::Escape;
$_ = uri_unescape "a%5eb";
Both will result in $_ eq "a^b".
and Yes, it will handle "9%25EA" correctly, tranforming it to "9%EA" and not eating the output %. See s///g.
(What's 9%EA? maybe fair share for 11-way split, less crumbs.)
-- Bill / n1vux
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.