in reply to Array Normalization of File::DirWalk
There's another way, which would not be dependent on the assumption that the original listing will always be ordered like that, but it involves post-processing after the DirWalk thing is done:
@folder = sort @folder; my $npaths = scalar @folder; push @folder, "~~~"; @folder = grep /./, map { (index($folder[$_+1], "$folder[$_]\\") == 0) ? '' : $f +older[$_] } ( 0..$npaths );
That is, sort the array and eliminate an element if it is fully contained as an initial substring of the next element. (The standard string sort will always put "a1" before "a1\1".)
Note that I added a bogus element on the array, to avoid an "undefined value" warning when map reaches the last directory. It's not elegant, alas...
|
|---|