I am building a system, where we have a large number of datastructures, that
- are constant, ie are readonly except for initialisation.
- are rarely used, ie in one run only a few percent will be used, depending on user input and so on.
- take a long time to initialise (they are read in from a database).
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
- fills in the tied variable
- unties it and leaves the data sitting there
Or is there another (and simpler) way of doing it??
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.