3 use Getopt
::Long qw
/:config no_ignore_case bundling no_getopt_compat/;
12 'v|vertical=s' => \
$char_vert,
13 'h|horizontal=s' => \
$char_hori,
14 'c|child=s' => \
$char_chld,
15 'l|last=s' => \
$char_last,
22 ) or pod2usage
(-exitval
=>2, -verbose
=>99);
27 %level_indent = (0=>0);
28 $Tree = { subtree
=>[], };
46 if($indent > $indent_prev)
49 $level_indent{$level} = $indent;
50 $ForkPoint = $ForkPoint->{subtree
}->[$#{$ForkPoint->{subtree}}];
52 elsif($indent < $indent_prev)
54 while($indent < $level_indent{$level})
57 $ForkPoint = $ForkPoint->{parent
};
61 push @
{$ForkPoint->{subtree
}}, {data
=>$data, parent
=>$ForkPoint, subtree
=>[]};
63 $indent_prev = $indent;
71 my $sidebranches = shift;
74 for my $node (@
$subtree)
76 my $last = $pos == $#$subtree;
80 printf "%s\n", $node->{data
};
82 print_subtree
($node->{subtree
}, $level+1, '');
88 for my $data (split /\n/, $node->{data
})
93 ?
($last ?
$char_last : $char_chld).$char_hori
94 : ($last ?
' ' : $char_vert).' ',
99 print_subtree
($node->{subtree
}, $level+1, $sidebranches . ($last ?
' ' : $char_vert.' '));
106 print_subtree
($Tree->{subtree
}, 0, '');
115 indent2tree - Makes TAB-indented text into ascii tree chart
123 =item -v, --vertical I<CHAR>
125 =item -h, --horizontal I<CHAR>
127 =item -c, --child I<CHAR>
129 =item -l, --last I<CHAR>
135 Input: lines with leading tabs representing the depth in the tree.
136 Multiline records are supported by terminating lines (all but the last one) by backslash.
138 Output: tree diagramm with (ascii or unicode) drawing chars.
139 Set custom drawing chars by B<-v>, B<-h>, B<-c>, and B<-l> options.
145 =item https://github.com/jez/as-tree