The fact that they are in separate packages has nothing to do with the fact that this is done endlessly, consuming all available resources. You call two methods from within each other. This is not a circular reference; it is a recursion , which is not the same. In particular, weaken won't help you at all. You will get exactly the same effect from:
sub a { b(); } sub b { a(); } a();
The best way to avoid this is to not do it . It is more useful if you have to write recursive functions, try not to use several functions in the recursion chain, but just one, so itβs easier for you to keep track of the time when your calls should end.
As for how to determine if something similar is happening, you need to do something simple, for example, increment a variable with recursion depth and end (or return) if your depth exceeds a certain value. But you really should not rely on this, it is like writing a while and using the increment there to make sure your function is not exhausted. Just don't relearn the kit unless you know how and when it ends.
Another pressing issue is what are you trying to accomplish first?
Adam bellaire
source share