One addendum to the existing answers. If you are running under mod_perl you will wants to 'use' all your modules during server startup rather than loading them as needed.

The reason is that modules loaded before Apache forks off children will usually share a lot of the memory they use between the various child processes. If you require the module at run time, you will load a _full_ copy into every child that uses it.

Unless those modules are used _extremely_ rarely, its generally going to be a memory loss under mod_perl.

Of course, there is a nice clarity to being able to look at the top of a script/module and see all the modules it uses. Also, if a module isn't there, its nicer to get a compile time error rather a runtime error halfway through execution.

Your approach is probably fine but I wouldn't want to do that myself unless I saw a really big impact.

-dave

In reply to Re: use vs. require by Anonymous Monk
in thread use vs. require by doran

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.