ramensaurus has asked for the wisdom of the Perl Monks concerning the following question:
I have two potentially basic questions about packages and scoping. I am self taught so I think that there may be a chance that there is something basic I'm not understanding here that can clear this up immediately. I have two different Perl modules, let's say package A and B.
Let's say that Package A uses Package B. However, as things become more complex, we find out that Package B needs to use some subroutines from Package A as well.
We know that we cannot just put use B; in Package A AND use A; in Package B because that would cause a circular reference. Also, we noticed that package B can call Package A subroutines directly without using use A;. While I can understand that there are package wide variables that can be accessed between the two packages, I don't understand how package B can call package A subroutines without using use A;
So the questions are:
1) What is the proper way to have package A and package B use each others subroutines without causing a circular reference?
2) Why is it that package B can use package A subroutines without using use A;
Let me know if more details are needed on my question - I hope that was clear.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Preventing Circular References in Modules
by GotToBTru (Prior) on Sep 16, 2015 at 20:19 UTC | |
by Anonymous Monk on Sep 16, 2015 at 23:23 UTC | |
|
Re: Preventing Circular References in Modules
by Anonymous Monk on Sep 16, 2015 at 19:55 UTC |