I am building a system, where we have a large number of datastructures, that

The structures are declared as globals, and whenever they are to be used an initialisation routine is called, which makes the code a bit clunky.

I have a nagging suspicion that I can do a "auto-init" using tie and some smoke and mirrors, so that on the first reference the structure is read in, untied and left as a normal datastruture.

Just tieing would work, but I think that the performance penalty is too high. Initialising all structures would require too much time (and far too much memory), so that is not an option either.

Anybody got any good ideas for the "auto init", ie a FETCH function, that

Or is there another (and simpler) way of doing it??


In reply to Using tie to initialize large datastructures by htoug

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.