Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Deep recursion problem

by ikegami (Pope)
on Oct 21, 2011 at 16:56 UTC ( #932936=note: print w/ replies, xml ) Need Help??


in reply to Deep recursion problem

it has something to do with perl's depth limit being 100

It's not a limit. Perl will happily continue to recurse until it runs of memory. It just warns you when you reach a depth of 100.

and that there is a $DB:deep variable that allows you to change this depth.

No there isn't. $DB::deep instructs the debugger to break at a certain recursion depth. It has no effect outside the debugger, and it doesn't affect the warning because the warning is always disabled when using the debugger.

As stated in perldiag, "this threshold can be changed from 100, by recompiling the perl binary, setting the C pre-processor macro PERL_SUB_DEPTH_WARN to the desired value."

I'd like to have a very large array, use this recursive subroutine, and get no warnings

That's what no warnings 'recursion'; is for.


Comment on Re: Deep recursion problem
Select or Download Code
Re^2: Deep recursion problem
by hexcoder (Hermit) on Feb 01, 2013 at 16:37 UTC
    As stated in perldiag, "this threshold can be changed from 100, by recompiling the perl binary, setting the C pre-processor macro PERL_SUB_DEPTH_WARN to the desired value."

    Hmmm... there are two cases: with or without running the debugger. I assume you meant the case without the debugger.

    With the debugger, one can set the threshold higher than 100 interactively prior to running the program, for example:

    DB<1> $DB::deep=1000 DB<2> ...

    This is now part of my debugger initialization file.

      Hmmm... there are two cases: with or without running the debugger. I assume you meant the case without the debugger.

      No, I meant what I said. $DB::deep has no effect on the warning. Ever.

      With the debugger, one can set the threshold higher than 100 interactively prior to running the program

      That's not true.

      >perl -dwe"$DB::deep = 1000; sub f { f($_[0]-1) if $_[0]; } f(150);" Loading DB routines from perl5db.pl version 1.37 Editor support available. Enter h or 'h h' for help, or 'perldoc perldebug' for more help. main::(-e:1): $DB::deep = 1000; sub f { f($_[0]-1) if $_[0]; } f(150 +); DB<1> r Deep recursion on subroutine "main::f" at C:/Progs/perl5161-ap1601/lib +/perl5db.pl line 3550. at C:/Progs/perl5161-ap1601/lib/perl5db.pl line 3550. ...

      See the post to which you replied if you want to know what $DB::deep actually does.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2014-12-18 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (59 votes), past polls