URL addresses only accepts alphanumeric characters and some punctuation symbols, like parenthesis and underscore.
If you need to use any other symbol (like space) you have to URL encode it using a percent sign followed by the two hexadecimal digits that represents that digit in the ASCII table.
For example, the space symbol is character 32 (hexadecimal 20) in the ASCII table, so it's expressed as %20.
In Perl, the easiest way to URL encode a string is to use uri_escape() function from URI::Escape module. This function converts all the unsafe symbols of a string to its URL encode representation.
Conversely, uri_unescape() converts a URL encoded string to its normal representation.
my $string = "Hello world!";
my $encode = uri_escape($string);
print "Original string: $string\n";
print "URL Encoded string: $encode\n";