in reply to problem endcoding URLs with embedded spaces

try using this :
$url =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;