in reply to Re^2: Sharing Namespaces
in thread Sharing Namespaces
Yes, on use/require perl checks whether $INC{<modulepath>} exists (<modulepath> being e.g. "My/Module/Namespace") and if so does not attempt to load the module again. This behaviour can be conveniently exploited when mocking modules (see chromatic's MockObject tutorial for more on this).
Update: note, this does not mean that the original module's code only gets run once, so e.g. if your Config module loads a configuration file it will still reload that file every time the module is called. It just means that the module's .pm file only gets loaded once and the code isn't duplicated in memory.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Sharing Namespaces
by ysth (Canon) on Jan 27, 2006 at 11:00 UTC | |
|
Re^4: Sharing Namespaces
by Anonymous Monk on Jan 29, 2006 at 00:29 UTC |