All,
As my ever expanding circle of knowledge increases, I begin to examine things that I took for granted previously. Perl is a wonderful language that worries about a lot of things for you. My current quest is to assimilate memory saving techniques.

It may seem counter intuitive at first, but a great methodology I like to use to learn new things is throw out my tool box and solve an old problem. Plato said "Necessity is the mother of invention". In other words, we tend not to explore when what we have works. This is only a catalyst process. Unless the new tool is actually superior, I use the old tool to solve the problem when it comes up. The new tool usually fits better somewhere else yet undiscovered.

In this particular case, I am trying to conserve as much space as possible in what would otherwise be a hash of arrays (HoA). Since I know inadvance exactly how many bytes total each array needs to be, I was hoping to use the equivalent of a C struct with pack/unpack resulting in a single hash. The trouble is that I need to include a reference and have it still work when it is unpacked.

As you can see, it is unlikely that this solution is a good fit to this problem. This doesn't mean it isn't worth pursuing since it is only an intermediate process. In fact, I doubt any process that converts a stringified reference back into a reference is very safe but the hunt for knowledge must go on. Does anyone know of a canned solution for this? In the chatterbox, tye indicated he believed there was an XS module but I couldn't find it. japhy is off working on one because it intrigued him as well.

While the problem outlined is my main focus at the moment, any memory saving/controlling techniques would be appreciated.

Cheers - L~R


In reply to Techniques On Saving Memory by Limbic~Region

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.