Consider that I have 100 Perl modules in 12 directories. But, looking into the main Perl script, it looks like 100 use p1 ; use p2 ; etc. What is the to best way to solve this issue?
Consider that I have 100 Perl modules in 12 directories. But, looking into the
Share
It seems unlikely to me that you’re
useing all 100 modules directly in your main program. If your program uses a function in module A which then calls a function from module B, but the main program itself doesn’t reference anything in module B, then the program should onlyuse A. It should notuse Bunless it directly calls anything from module B.If, on the other hand, your main program really does talk directly to all 100 modules, then it’s probably just plain too big. Identify different functional groupings within the program and break each of those groups out into its own module. The main reason for doing this is so that it will result in code that is more maintainable, flexible, and reusable, but it will also have the happy side-effect of reducing the number of modules that the main program talks to directly, thus cutting down on the number of
usestatements required in any one place.(And, yes, I do realize that 100 was probably an exaggeration, but, if you’re getting uncomfortable about the number of modules being
used by your code, then that’s usually a strong indication that the code in question is trying to do too much in one place and should be broken down into a collection of modules.)