hi,
I have some code that uses flat files with the following format :
key|field1=val1|field2=val2|field3=val3|
I have successfuly used Tie::StdHash to put this into :
$hash{key}{fieldN}
structure...up to now everything is ok...
Now as u may alredy guessed the hard part is to, make STORE works efectively..
The simplest way is to just rebuild the text file into string and then slurp the result into the file every STORE
What other tehniques i can employ to make things better
The things become worse 'cause I will have not one but several files and I will want to be able to support simultaneous access via flock() probably..
So if i make some sort of caching i have to do longer locks..
FYI I dont expect too many simultaneous access, but has to have it as a feature...
One more thing I dont want to use SQL or DBM, why :
- the files will be maximum several thousand entires/lines
- I can edit the files with text editor.
- I can easly grep files with regexes to make some stuff that are horribly hard with SQL.
- DB is noneditable, but is also a option if lines goes over 10 000 :"), 'cause it too can be hidden behind a HASH

If I decide to move this into SQL DB, i will probably hide it behind HASH access(there is such module AFAIK), that is one of the reasons I move to Tie::Hash.

In reply to 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.