Subject: | Path Ancestor match a false Ancestor with the following example |
Date: | Mon, 3 Jul 2017 20:17:36 +0200 |
To: | bug-Path-Ancestor [...] rt.cpan.org |
From: | Jan Bottek <jan.bottek [...] gmail.com> |
Hi Mike Schilli,
with the following example, the great Path::Ancestor module will match a
wrong Ancestor path
-----------------------------------------------------------
use strict;
use warnings;
use Path::Ancestor qw(longest_common_ancestor);
my @pathes = ("/foo/bar/baz",
"/foo/bar/baz/moo",
"/foo/bar1/qasa" );
# possible solution
my $ancestor = longest_common_ancestor(
@pathes
);
print "Wrong: $ancestor";
print "\n";
@pathes = reverse sort @pathes;
$ancestor = longest_common_ancestor(
@pathes
);
print "with Ancestor patch: $ancestor";
-----------------------------------------------------------
Stupid patch from my site was to reverse/sort the entry pathes.
What do you think about it?
Thx in Advance.
Kind regards.
Jan Bottek