(Which is not the same as misusing
Uri)
I just realized I could use URI to make full pathnames into relative pathnames:
my $dispname = URI->new("file://$filename")->rel("file://$startpath");
This way, if
$filename="/home/alester/tw/intro/about.html"
and
$startpath="/home/alester/tw/"
then
$dispname="intro/about.html"
That construct, modulo the "file://", is stolen from
Sean Burke's excellent
Perl & LWP, page 56.
File::Spec
vsergu on 2002-08-06T22:24:37
File::Spec has an abs2rel() method to do that, and should handle OS-specific path separators as well.
Of course, that doesn't have the fun of misuse.
Re:File::Spec
petdance on 2002-08-07T01:40:08
ARGH. I can't tell you how many times I went over File::Spec in Perl In A Nutshell looking for something like that. I wonder if it's missing, and I should have stuck to the man pages.
Thanks for pointing it out.