Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Turn off FATAL warnings in 3rd party module

by thanos1983 (Parson)
on Jun 03, 2019 at 15:05 UTC ( #11100878=note: print w/replies, xml ) Need Help??


in reply to Turn off FATAL warnings in 3rd party module

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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11100878]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2020-06-01 17:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (6 votes). Check out past polls.

    Notices?