I have this piece of code for simple url encoding:
$enc_url= 'http://example.com/exampledir/file.pl';
$enc_url=~ s/(\W)/ '%' . sprintf('%02x',ord($1)) /ge ;
Now, it does exactly what I want but it returns the encoded url with lowercase characters
So I get:
http%3a%2f%2fwww%2eexample%2ecom%2fexampledir%2ffile%2fpl
but I want (for my own readability):
http%3A%2F%2Fwww%2Eexample%2Ecom%2Fexampledir%2Ffile%2Epl
I have tried:
$enc_url=~ s/(\W)/ uc('%' . sprintf('%02x',ord($1))) /ge ;
as well as:
$enc_url=~ s/(\W)/ '%' . uc(sprintf('%02x',ord($1))) /ge ;
and:
$enc_url=~ s/(\W)/ '%' . sprintf('%02x',uc(ord($1))) /ge ;
with no luck.
I note that a similar question for another language here (Get string from Server.UrlEncode as uppercase) has a lot of quesries on why the need to change to uppercase which I understand but I still will like to if possible/trivial to do.
Main thing is that I can not use the URI::Escape or similar modules.