use strict; is a good idea, but that is a different thing that "use ModuleX;

"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.


In reply to Re: Using variables in require file... not possible? by Marshall
in thread Using variables in require file... not possible? by tunafish

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.