#!/usr/bin/perl -- use strict; use warnings; use URI; my $base = 'http://foobert.org/dir/odir'; my $file = 'foo.html'; my $uri = URI->new($base); local $\=$/; print $uri->path_segments( $uri->path_segments, $file ); print $uri; print $uri->host('I-RTFM.org'); print $uri; __END__ dirodir http://foobert.org/dir/odir/foo.html foobert.org http://I-RTFM.org/dir/odir/foo.html