6 lines
175 B
Perl
6 lines
175 B
Perl
sub common_prefix {
|
|
my $sep = shift;
|
|
my $paths = join "\0", map { $_.$sep } @_;
|
|
$paths =~ /^ ( [^\0]* ) $sep [^\0]* (?: \0 \1 $sep [^\0]* )* $/x;
|
|
return $1;
|
|
}
|