I know I'm several years late to the party with this, but we recently, finally, updated URI::Escape. I'm sure it's all real up-to-date and real correct and real conformant with the latest RFC and whatever, but I liked it better when it just worked, DWIM.
#!/usr/bin/perl
use URI::Escape;
my $link = 'httpd://www.example.com/stuff/this and that.pl?foo=bar';
$link = uri_escape($link);
if ($gimme_what_i_want) {
$link =~ s!%2F!/!g;
$link =~ s!%3A!:!g;
$link =~ s!%3F!?!g;
$link =~ s!%3D!=!g;
}
print "$link\n";
__DATA__
the old way:
httpd://www.example.com/stuff/this%20and%20that.pl?foo=bar
the new way:
httpd%3A%2F%2Fwww.example.com%2Fstuff%2Fthis%20and%20that.pl%3Ffoo%3Db
+ar
Is the old encoding method available through another module? Should I subclass the new one to rebreak it? If I have to tell every character I do or don't want to escape, I might as well write my own...
YuckFoo
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.