#!/usr/bin/perl my $s1 = "//depot/Efp/Celox/CELOX-3.5.0/CeloxStart.sln"; my $s2 = "//depot/Efp/Celox/MAIN/CeloxStart.sln"; @s1 = split "/", $s1; @s2 = split "/", $s2; my $i = 0; $i++ while $s1[$i] eq $s2[$i]; # find end of common beginning my $j = -1; $j-- while $s1[$j] eq $s2[$j]; # find beginning of common end print join("/", @s1[$i..(@s1+$j)]), "\n"; print join("/", @s2[$i..(@s2+$j)]), "\n";