Have you looked at using "our" instead of "my" to declare the variables that are used in both the main source code file and the various subroutine code files that it "require"s? That would allow you to keep the code separated into files as it is now: when variables are declared with "our" instead of "my", perl will treat them as having scope beyond any single source code file.
Of course, that's a procedural short-cut -- a relatively messy expedient. A theoretically cleaner, more maintainable solution is that the various subroutines stored in separate files would be modified not to use global variables. Instead, to get a fully satisfying solution, you would do one of the following:
- if the subroutines are using (and modifying) global variables "owned by" (first declared in) the main code file, then each of the subs (and sub calls) would be modified so that those globals are passed (by reference) as parameters to the subroutines, or
- if the subs are "creating" global variables that are subsequently used in the main code (a particularly nasty habit, IMHO), they would be organized into packages (typically one package per source file, but you can choose to have one source file with multiple package ... declarations) and would be "objectified" so that the variables they create are accessible via objects that are given to the caller via a "new()" function (which is surprisingly simple to do), or
- some combination of the above, depending on what your current "require"d files are doing.
If that raises any procedural questions for you, please post some relevant code to demonstrate the issue.
(P.S. (update): Welcome to the Monastery! I could tell right away that you're a new monk, because if you'd been around longer, you would have heard about "use strict" earlier...)