sub relpath { my ($from, $to) = @_; my @f = split '/', $from; my @t = split '/', $to; while (@f and @t) { shift(@f), shift(@t), next if $f[0] eq $t[0]; return join '/', ("..") x @f, @t; } return "./"; }