| View previous topic :: View next topic |
| Author |
Message |
komi
Joined: 27 Nov 2009 Posts: 159
|
Posted: Mar 08, 2010 7:32 am Post subject: How to fully encode a URL? |
|
|
Hello,
I have to know how to fully encode an url in perl. I temporarily did this with JavaScript, but would like to do it via the script.
Thanks in advance. |
|
| Back to top |
|
 |
mrperl
Joined: 06 Mar 2010 Posts: 65
|
Posted: Mar 08, 2010 10:38 am Post subject: Re: How to fully encode a URL? |
|
|
Hi komi.
Depends on what you mean by encoding/escaping and where the
result will be used.
XFS Pro includes a copy of CGI::Simple, so that's one way to encode a url.
| Code: |
use strict;
use diagnostics;
use lib 'Modules'; # customize this for your XFS Pro installation
use CGI::Simple;
my $q = new CGI::Simple;
my $url = 'http://sample.com/file 1.html'; # embedded space
my $encoded = $q->url_encode($url);
print $encoded, "\n";
|
The result is:
| Code: |
http%3A%2F%2Fsample.com%2Ffile+1.html
|
Thanks, mrperl.
http://search.cpan.org/dist/CGI-Simple/lib/CGI/Simple.pm |
|
| Back to top |
|
 |
komi
Joined: 27 Nov 2009 Posts: 159
|
Posted: Mar 08, 2010 11:40 am Post subject: |
|
|
| Perfect! Thanks. |
|
| Back to top |
|
 |
|