#!/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%3Dbar