in reply to Re^2: Using a module more than once
in thread Using a module more than once
Or am I misunderstanding how that mechanism works?You are. Any module that gets used, will be loaded at compile time, thus, when your module is loaded. So there's no use in putting a use statement inside a method.
Sometimes, when some modules are only needed in exceptional circumstances, people can use a require statement in a method or sub, for example to load Carp in an error trapping routine.
You have to be aware of the differences between use and require: require doesn't call import in the loaded modules, and it won't change the allowable syntax for your code either. Thus, subs defined in that module won't be easily recognized as such in the loading script. It's something to look out for.
For OO modules, it makes no difference, whether you choose use or require.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Using a module more than once
by techra (Pilgrim) on Aug 02, 2005 at 17:04 UTC | |
by bart (Canon) on Aug 02, 2005 at 17:11 UTC | |
by techra (Pilgrim) on Aug 02, 2005 at 17:27 UTC |