use File::Spec; my $filepath = File::Spec->catfile( $dir, $filename ); #### use File::Spec::Unix; use URI; my $uri = URI->new( $base ); $uri->path( File::Spec::Unix->catfile( $uri->path, 'foo.html' ) );