use Tree::Parser; my $tp = Tree::Parser->new($input); $tp->useSpaceIndentedFilters(2); my $tree = $tp->parse(); #### $tree->traverse(sub { my ($t) = @_; print(("\t" x $t->getDepth()) . $t->getNodeValue() . "\n"); }); #### my $deparsed_tree = $tp->deparse(); print $deparsed_tree; # or in array context you get an array of lines my @lines = $tp->deparse(); print join "\n" => @lines; #### use Tree::Simple::VisitorFactory; my $visitor = Tree::Simple::VisitorFactory->get("BreadthFirstTraversal"); $tree->accept($visitor); print join ", " => $visitor->getResults(); # this prints : Building, House, Hut, Garage, Window, Door, Roof, Pizza, Door, Glas, Wood, Silicium