in reply to Encoding a URL with regular expressions?

Why use a regex at all?

#!/usr/bin/perl use strict; use warnings; use URI::URL; use URI::Escape; # added my $company_name = 'Inn House Company Services'; $company_name = uri_escape($company_name); # added my $partial_url = 'http://my.test.com?infor=info2&company_name=' . $co +mpany_name; my $url = URI::URL->new($partial_url); print $url, "\n";

Update: Added the two additional lines because $company_name might include other characters that need encoding. For example: 'Parker & Sons' and 'Giving 110%' both contain characters that are reserved. What if $company_name includes Unicode characters?. (URI::Escape appears to simply drop Unicode character.)