#!/usr/bin/perl
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
sub print_tree {
my $dir = shift;
my $pathname = [$_];
find ({ wanted => sub {
return if /^\.\.?$/;
printf "%s\n", join ('/', @$pathname, $_);
if (-d and not -l) {
push (@$pathname, $_);
}
},
preprocess => sub {
sort {
# Files sort before dirs
(-f $a ? (-f $b ? $a cmp $b : -1 ) : (-f $b ? 1 : $a cmp $b))
} @_
},
postprocess => sub {
pop (@$pathname);
},
}, $dir);
}
foreach (@ARGV) {
print_tree ($_);
}