in reply to "use" modules inside modules
Are there any assignments to this variable in module B? Are you using strictures (use strict; use warnings;) in module B? Do module A, B and the main program have package declarations? If so, what are they?
Perhaps module B is making an assignment to this hash? When it uses module A, it imports the variable from module A and overwrites its value. Then your main program sees the reassigned value. When it doesn't use module A, then it assigns the value to a variable in its own namespace instead of to the shared variable. Since the main program is using module A's version of the variable, it never sees the reassignment.
This kind of thing would be pretty obvious if you are using strictures. When you removed "use A" you would get complaints about an undeclared variable. But if you are not, you won't get such complaints.
But this is just a guess. For a better answer from me or others, I would recommend that you make a copy of all three modules and bit by bit remove code until you find the fewest lines of code needed to reproduce the problem. Then update your post with either the answer (if you nailed the reason for this behavior) or some sample code (if you did not).
Best, beth
|
|---|