| René Nyffenegger's collection of things on the web | |
|
René Nyffenegger on Oracle - Most wanted - Feedback
|
URI.pm [Perl] | ||
|
Let's say, we have an URL that we want to split in its part.
This can easily be done with Perl and URI.pm:
use URI;
my $uri = URI->new("http://xxx.yy.ch:8080/a/b/c.html?vier=4&fuenf=5");
print "Scheme: ",$uri->scheme,"\n";
print "Path: ",$uri->path ,"\n";
print "Host: ",$uri->host ,"\n";
print "Port: ",$uri->port ,"\n";
print "Query: ",$uri->query ,"\n";
This would print:
Scheme: http Path: /a/b/c.html Host: xxx.yy.ch Port: 8080 Query: vier=4&fuenf=5
Creating a new absolute URL out of a an absolute URL and a relative path:
use warnings; use strict; use URI; my $absolute_url = 'http://www.tld.com/one/two/three/page.html'; my $link = '../new_page.html'; print URI->new_abs($link, $absolute_url), "\n";
prints:
http://www.tld.com/one/two/new_page.html |