in reply to Re: Finding nested directories from a string list.
in thread Finding nested directories from a string list.
to:foreach my $path ( keys %paths ) {
# : N.B. We explicitly iterate over the paths in order of the # number of directory components. This is so we don't create # directories for a child path before creating directories for a # parent path. # : sort the keys to %path by the number of directory components and # then by a string compare. (both comparisons are ascending.) my @sorted_paths = sort { $a =~ tr/\\// <=> $b =~ tr/\\// || $a cmp $b } keys %paths; # : foreach $path in the @sorted_paths array foreach my $path (@sorted_paths) {
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Finding nested directories from a string list.
by QM (Parson) on Feb 27, 2006 at 16:58 UTC |