Is this a Garbage In Garbage Out issue? Those URLs are valid properly-formed URLs, they just do not point to anything on the server. What is creating the original URLs with the %20 embedded?
| [reply] [Watch: Dir/Any] [d/l] |
If you want to remove all the spaces, you need no module. Just use substitution: $url =~ s/%20//g;
If you want to remove only certain spaces, please specify how to recognise them.
| [reply] [Watch: Dir/Any] [d/l] |
"I have a problem with some links getting white spaces automatically"
How does the "automatically" part occur? The whitespace fairy doesn't pay you a visit... so when are these whitespaces being introduced? Usually that occurs when a file has a space in the filename, and a browser intelligently converts that space to a %20 to avoid a global meltdown. I think rather than converting the spaces, you should avoid them in the first place by fixing the source filenames (or what creates them if it's another process.)
In other words,
If you have a file called "sample file.html", and you want to access it via a browser, you will have to use "http://yourserver.com/sample%20file.html" to reference it. Instead of trying to fix the URL, remove the space in the file name, perhaps "sample_file.html", so your URL will not have any %20 characters present. Would that solve your problem? | [reply] [Watch: Dir/Any] |
Yes ... the whitespace fairy is a BUG coming from somewhere, and you need to trace that BUG to its true source, not just regex your way past the surface symptom.
| [reply] [Watch: Dir/Any] |
use warnings;
use strict;
use URI::Escape;
my $url = "http://192.168.1.50/cgi-bin/in%20dex.cgi?action=vi%20ew due
+ to %20";
my $uri = uri_unescape($url);
print $uri; # http://192.168.1.50/cgi-bin/in dex.cgi?action=vi ew due
+ to
But really, I will advice, you seriously consider sierpinski's wisdom on this issue.
Hope this helps
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
| [reply] [Watch: Dir/Any] [d/l] |
Please explain problem with code examples, so that we can get your context. | [reply] [Watch: Dir/Any] |