That kind of sharing probably requires copying to a certain extent. You might end up using
Storable to push it into a shared scalar, or
Cache::Memcached to do some of the magic for you, but I don't think there's a magic way to share a nested structure without ... nesting on either end of the share. I could be mistaken, but I don't think you can.
If you choose something like DB_File or DBM::Deep, you'll probably find the use of the local filesystem (if available) to be pretty darned efficient. IIRC, DB_File even handles buffering for you (the berkely db magic).
It is possible to write your own hash class with tie. You could make each key a shared scalar (using whatever method you like). Perhaps that's the best way if you have something really specific in mind, because then you can explicitly state what you want and perl will do it. :)
My thinking is that you might be accustomed to sharing huge segments of memory in C/C++. I'm not sure there's anything directly comparable in perl — though I wouldn't be surprised if there were. As a last resort, you could write something in XS or Inline::C. That sounds pretty interesting to me.
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.