in reply to Using variables in require file... not possible?
"use ModuleX;" is a compile thing. And Module X will be compiled. require is a run time time thing - as far as I know.
Most of my modules (but not all) are function oriented as opposed to OO. These modules export subroutine names that can be used by the "caller", the Perl code that "uses" the module can access these symbols. I can export function names or actually even "our" variables and I can export names either by default or by request.
If I have an procedure oriented module, your interface to is is only via the symbols that I chose to export or allow you the import optionally. Basically exporting those symbols means that these name go into the package name space.
An OO module is different in that not every method is necessarily in a symbol in the package table and there is more overhead to call a method in an OO package.
When I "use ModuleX", it gets complied and executed. Require means that it must be there, but no code within it will be compiled and run until it is needed in the code.
Normally you should "use" modules that you write yourself. "require" is actually a kind of "rare duck" and is used in special circumstances.
|
|---|