#!/usr/bin/perl -w use strict; use Tree::Simple; my $CR="\n"; my @array = qw/ 112.75 850.22 100.65 1651.82 21.82 1598.36 962.97 15.10 85.55 112.75 850.22 21.82 1651.82 1598.36 962.97 /; for (my $j=0;$j<10**10;$j++) { #always the same code to execute my $i=0; my $tree = Tree::Simple->new("root tree",Tree::Simple->ROOT); printleaf(\$tree); $tree->addChild(Tree::Simple->new("$array[$i]")); printleaf(\$tree->getChild(0)); my @_auxarray=@array; splice(@_auxarray,$i,1); foreach my $elem (@_auxarray) { printleaf(\Tree::Simple->new("$elem",$tree->getChild(0))); } undef @_auxarray; $tree->DESTROY(); #clear circular references $tree->traverse(sub { my($_tree)=@_; print (("\t" x $_tree->getDepth()), $_tree->getNodeValue(),"\n"); }); undef $tree; } my $pause=; #variable only used to pause the program sub printleaf{ my ($_leaf)=$_[0]; print("VALUE: ",$$_leaf->getNodeValue()," | ROOT?: ",$$_leaf->isRoot() ? "true" : "false"," | DEPTH: ",$$_leaf->getDepth()," | INDEX: ",$$_leaf->getIndex(),"$CR"); }