8 my $stop_pattern = undef;
12 's|sort!' => \
$do_sort,
13 'd|separator|dir-separator=s' => \
$DIRSEP,
14 't|stop=s' => \
$stop_pattern,
15 ) or pod2usage
(-exitval
=>2, -verbose
=>99);
19 while(my $line = <STDIN
>)
23 my ($path, $sep, $suffix);
25 if(defined $stop_pattern)
27 ($path, $sep, $suffix) = split /($stop_pattern)/, $line, 2;
35 my @elements = split /\Q$DIRSEP\E/, $path;
36 $elements[$#elements] .= $sep . $suffix if @elements;
38 for my $element (@elements)
40 next if $element eq '';
41 $ref->{'children'}->{$element} = {
42 'index' => (scalar keys %{$ref->{'children'}}),
45 } if not exists $ref->{'children'}->{$element};
46 $ref = $ref->{'children'}->{$element};
54 for my $child (sort {$do_sort ?
($a->{'name'} cmp $b->{'name'}) : ($a->{'index'} <=> $b->{'index'})} values %{$ref->{'children'}})
56 printf "%s%s\n", "\t"x
$indent, $child->{'name'};
57 output
($indent+1, $child);
70 paths2indent - Transform list of filesystem paths to an indented list of the leaf elements
74 paths2indent [I<OPTIONS>]
78 Input: list of file paths line-by-line
80 Output: leaf file names indented by as many tabs as deep the file is on the tree
86 =item -d, --separator I<CHAR>
88 =item -t, --stop I<PATTERN>
96 Can not have empty path elements (ie. consecutive slashes).
102 =item https://github.com/jez/as-tree