in reply to A lil module creation advice
Are the modules in question .pm files being used (pulled in at compile time) or .pl files being required (at run time)?
I suspect the former. If a used file is pulled in, any mainline code (not part of a sub) actually gets run at compile time - as if it were in a BEGIN block.
This is handy for initialisation code, but if your colleague is stuffing application code in here, it will indeed happen at compile time.
On the subject of package main;, this just means that any subs will be placed in the main:: namespace, thus defensively negating any package declaration prior to calling the module. IMO this should not be done, as the module should not be dictating the namespace to its caller, (unless we are talking OO, which is a different ball game).
Also note that leaving the use or require restores the namespace to that of the calling code.
For more on this, see perldoc perlfunc sections on use and require. I also recommend buying a copy of the Camel book for your colleague.
I may be able to answer more specifically if you post some code.
hth
--rW
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A lil module creation advice
by snafu (Chaplain) on Apr 21, 2002 at 03:26 UTC | |
by rinceWind (Monsignor) on Apr 21, 2002 at 09:38 UTC |