I can't vouch for the wisdom of one approach over another, but here's what I've done in the past:

If all I want to import are a batch of config variables, I've require'd a file consisting of subs that return some value or another, like:

# Contents of config.pl sub big_list { return qw(some enormous list of variables); } # And then in my program... require config.pl; my @big_list = big_list();
If I want to import some simple set of subroutines (housekeeping stuff mostly... subs that don't really belong anywhere else) I'll make a file of subs and require them like before, except I'll (obviously) pass values into and out of the sub instead of just "out" as above. If you have a truly global variable that you want your imported subs to see, use "use vars " or "our" to declare your global variable.

Of course, if I have a batch of config variables or subs that actually belong together the best place is to put it into a full-blown module. I won't build a module unless it makes sense, though. I have literally used all three techniques in different parts of the same project. Whichever fits you best. All three techniques are ways to re-use code, and re-using code is right up there with cleanliness and godliness. So, at least in my opinion, it's aaallllll gooooooddddd.

Gary Blackburn
Trained Killer


In reply to Re: Trying to be stricter... by Trimbach
in thread Trying to be stricter... by Henri Icarus

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.