File-Slurp-Tree
view release on metacpan or search on metacpan
lib/File/Slurp/Tree.pm view on Meta::CPAN
(my $top = $in) =~ s{/$}{};
my $rule = $args{rule} || File::Find::Rule->new;
my $tree = {};
for my $file ( $rule->in( $in ) ) {
next if $file eq $top;
(my $rel = $file) =~ s{^\Q$top\E/}{};
next unless $rel; # it's /
#print "top:$top file:$file rel:$rel\n";
my @elems = split m{/}, $rel;
# go to the top of the tree
my $node = $tree;
# and walk along the path
while (my $elem = shift @elems) {
# on the path || a dir
if (@elems || -d $file) {
$node = $node->{ $elem } ||= {};
}
else {
( run in 0.466 second using v1.01-cache-2.11-cpan-71847e10f99 )