One good way to approach things is to say that all of your modules will contain 'subroutines' or 'objects,' and if necessary maybe a subroutine that creates a singleton object-instance on demand. Now you have a well-defined way for things to be initialized, and while the methods of the object are executing they have a well-defined "place to put things," i.e. the object itself. This also naturally encourages you to put the logic where it properly belongs ... right there alongside the data that's being manipulated. Values can easily be initialized either in the "new()" method, or lazily, on-demand, and all of that plumbing-work is right there where you'd expect it to be, not scattered all over the application. It works out really well in practice.

In reply to Re: How to initialize a Global in a module by Anonymous Monk
in thread How to initialize a Global in a module by Henric

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.