The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

NAME

Tree::Simple::View::ASCII - A class for viewing Tree::Simple hierarchies in ASCII

SYNOPSIS

my $tree_view = Tree::Simple::View::ASCII->new($tree);
$tree_view->includeTrunk(1);
print $tree_view->expandAll();
# root
# |---Node Level: 1
# | |---Node Level: 1.1
# | |---Node Level: 1.2
# | | |---Node Level: 1.2.1
# | | \---Node Level: 1.2.2
# | \---Node Level: 1.3
# |---Node Level: 2
# | |---Node Level: 2.1
# | \---Node Level: 2.2
# |---Node Level: 3
# | \---Node Level: 3.1
# | |---Node Level: 3.1.1
# | \---Node Level: 3.1.2
# \---Node Level: 4
# \---Node Level: 4.1
print $tree_view->expandPath("root", "Node Level: 1", "Node Level: 1.2");
# root
# |---Node Level: 1
# | |---Node Level: 1.1
# | |---Node Level: 1.2
# | | |---Node Level: 1.2.1
# | | \---Node Level: 1.2.2
# | \---Node Level: 1.3
# |---Node Level: 2
# |---Node Level: 3
# \---Node Level: 4
my $tree_view = Tree::Simple::View::ASCII->new($tree, (
characters => [ indent => " ", pipe => " | ", last_branch => " \- ", branch => " |- " ]
) );
# root
# |- Node Level: 1
# | |- Node Level: 1.1
# | |- Node Level: 1.2
# | | |- Node Level: 1.2.1
# | | \- Node Level: 1.2.2
# | \- Node Level: 1.3
# |- Node Level: 2
# |- Node Level: 3
# \- Node Level: 4

DESCRIPTION

This is a Tree::Simple::View subclass which provides simple ASCII formatting for trees.

I had this code lying around, and I figured it was best to put it into here. This is an early release of this, and it lacks configuration parameter handling, but that can be easily added later when I need it.

METHODS

expandAllSimple

This will draw a fully expanded tree.

expandAllComplex

This currently is aliased to the expandAllSimple since we don't have config handling.

expandPathSimple (@path)

This will draw a tree with the given @path expanded.

expandPathComplex

This currently is aliased to the expandPathSimple since we don't have config handling.

TODO

Config handling, allowing you to customize the drawing. Patches welcome, I just don't currently have the time to add it.

Repository

https://github.com/ronsavage/Tree-Simple.git

SUPPORT

Bugs should be reported via the CPAN bug tracker at

https://github.com/ronsavage/Tree-Simple/issues

AUTHOR

stevan little, <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Copyright 2004-2008 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.