Although in some cases I might want to allow deep recursions in my code, I want to be able to disable it in certain cases (like while testing).
I know that when using the debugger I can use $DB::deep to specify the maximum recursion depth, and the feature I'm after is basically the same but usable even when not in the debugger.
I took a look in CPAN, but I couldn't find anything. And a search on PerlMonks lead me to a thread about changing the behaviour of the deep recursion warning. What I'm after is a to be able to block recursions altogether (eg. die if the recursion gets too deep).
Does this feature exist?
Bonus points if the solution allows me to localise it, so that I can control the scope of a maximum recursion depth.