eyepopslikeamosquito has asked for the wisdom of the Perl Monks concerning the following question:
This came up during a code review today. I was reviewing code like this:
Now, I tend to put all use statements at the top of the file. Occasionally, I might put a require statement inside a sub if the module is big and slow to load or unavailable on some platforms, because require is performed at run time. However, given that use statements are performed at compile time, it seems confusing to me to put a use statement inside a sub.sub some_function { use SomeModule; # ... }
I couldn't find any style advice on this issue in either Perl Best Practices or Perl::Critic. What advice would you give?
Back to
Seekers of Perl Wisdom