Hello bliako,

If you enable use diagnostics; you will see the following:

$ 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!

In reply to Re: Turn off FATAL warnings in 3rd party module by thanos1983
in thread Turn off FATAL warnings in 3rd party module by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.