RosettaCodeData/Task/Find-common-directory-path/Perl-6/find-common-directory-path-3.pl6
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

8 lines
310 B
Raku

my $sep = '/';
my @dirs = </home/user1/tmp/coverage/test
/home/user1/tmp/covert/operator
/home/user1/tmp/coven/members>;
sub is_common_prefix { so $^prefix eq all(@dirs).substr(0, $prefix.chars) }
say ([\~] @dirs.comb(/ $sep [ <!before $sep> . ]* /)).reverse.first: &is_common_prefix