Help for this page

Select Code to Download


  1. or download this
    use Tree::Parser;
    my $tp = Tree::Parser->new($input);
    $tp->useSpaceIndentedFilters(2);
    my $tree = $tp->parse();
    
  2. or download this
    $tree->traverse(sub {
       my ($t) = @_;
       print(("\t" x $t->getDepth()) . $t->getNodeValue() . "\n");
    });
    
  3. or download this
    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;
    
  4. or download this
    use Tree::Simple::VisitorFactory;
     
    ...
    
    print join ", " => $visitor->getResults();
    # this prints : Building, House, Hut, Garage, Window, Door, Roof, Pizz
    +a, Door, Glas, Wood, Silicium