Search notes:

Perl module URI

The Perl module URI can be used to split an URL into its parts
#!/usr/bin/perl
use warnings;
use strict;

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";
Github repository PerlModules, path: /URI/script.pl
This script prints
Scheme: http
Path:   /a/b/c.html
Host:   xxx.yy.ch
Port:   8080
Query:  vier=4&fuenf=5

Combining absolute and relative urls

new_abs can be used to create an absolute url from an existing absolute and relative url.
#!/usr/bin/perl
use warnings;
use strict;

use URI;

my $absolute_url = 'http://www.host.xyz/path/to/a/page.html';
my $relative_url = '../../of/another/resource.html';

print URI->new_abs($relative_url, $absolute_url), "\n";
Github repository PerlModules, path: /URI/combine-absolute-and-relative-url.pl
prints
http://www.host.xyz/path/of/another/resource.html

See also

Perl modules, URI::Encode URI::Find
URI: Uniform Resource Identifier

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759391181, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/URI/index(84): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78