Note that File::Spec's
offers a abs2rel method which does a very
similar thing. It is more portable -- it will
work on the MacOS, VMS, etc.
The only difference I can see is
that it does not resolve symbolic links before computing
the relative path, something that can be easily worked
around.