Thread relativen Pfad ermitteln
(45 answers)
Opened by jan99 at 2010-08-28 12:41 2010-08-28T10:41:16 jan99 Ich benutze dazu folgende Funktion: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 sub rel_path($$) { my ($target,$start) = @_; $start =~ s:/[^/]+:/:; # remove trailing filename my @spath = grep {$_ ne ''} split(/\//,$start); my @tpath = grep {$_ ne ''} split(/\//,$target); # strip common start of the path while ( @spath && @tpath && $spath[0] eq $tpath[0]) { shift @spath; shift @tpath; } return ("../"x(@spath)).join('/', @tpath); } Ciao, Claus Last edited: 2010-08-29 18:30:53 +0200 (CEST) |