snafu,

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


In reply to Re: A lil module creation advice by rinceWind
in thread A lil module creation advice by snafu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.