$ perl test.pl
Deep recursion on subroutine "Tree::_fix_height" at
/usr/local/share/perl/5.26.2/Tree.pm line 333 (#1)
(W recursion) This subroutine has called itself (directly or indir
+ectly)
100 times more than it has returned. This probably indicates an
infinite recursion, unless you're writing strange benchmark progra
+ms, in
which case it indicates something else.
This threshold can be changed from 100, by recompiling the perl bi
+nary,
setting the C pre-processor macro PERL_SUB_DEPTH_WARN to the desir
+ed value.
Uncaught exception from user code:
Deep recursion on subroutine "Tree::_fix_height" at /usr/local/sha
+re/perl/5.26.2/Tree.pm line 333.
Tree::_fix_height(Tree=HASH(0x5614409803c0)) called at /usr/local/
+share/perl/5.26.2/Tree.pm line 333
Tree::_fix_height(Tree=HASH(0x561440992cc8)) called at /usr/local/
+share/perl/5.26.2/Tree.pm line 333
.
.
.
The error is not on the module Tree it is the limit that Perl has by default for recursions.
(W recursion) This subroutine has called itself (directly or indir
+ectly)
100 times more than it has returned.
The only way to modify this is:
This threshold can be changed from 100, by recompiling the perl binary
+,
setting the C pre-processor macro PERL_SUB_DEPTH_WARN to the desir
+ed value.
Unfortunately this is not a local modification of the module it will affect the Perl binary on you OS.
I will keep looking into it in case I will find something more than that, I will update the post. I am sure other Monks will have much deeper knowledge on this.
Update: If you change the format on the way you add child and you add specific position to the function add_child() the loop will not become recursive. The function will return TRUE after execution and you will not have this problem. Sample of code from the module documentation Tree "modified slightly to your needs":
#!/usr/bin/perl
use strict;
use warnings;
use Tree;
my $tree = Tree->new('root');
foreach my $i (0..200){
$tree->add_child( { at => $i }, Tree->new( "child $i" ) );
}
print "success\n";
__END__
$ perl test.pl
success
BR / Thanos
Seeking for Perl wisdom...on the process of learning...not there...yet!
|