You may want to have a look at Tie::File, which has a read cache and deferred write mode. (It ties an array to lines in the file; you would want to munge it to tie a hash based on the key.) But the caching isn't going to work for you if you really need simultaneous access.

You've constrained your problem so well it becomes hard to solve except with whole-file writes on every change. About the only thing I can think of that would help would be to have a maximum record length, and pad the end of each line out to that length. Then you can update a single line on each STORE. But it makes it easy to mess yourself up when you directly edit the file.


In reply to Re: tie::hash files.. by ysth
in thread tie::hash files.. by bugsbunny

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.