If you're working with a flat-file, using it to represent records, you've got some issues to deal with. First, if the individual records aren't fixed-length, then you need to maintain an index, or suffer the performance penalty of simply having to skim the entire file just to find one record. Additionally, any change you make (again, assuming the records are not of fixed length) will mean you have to rewrite the file, or mark an existing record null and void, and append its replacement at the end of the flat file (which further hampers searchability). In other words, a non-fixed-length flat file based records approach is kinda messy and speed inefficient.

On the other hand, flat files with fixed length records would allow for rewriting individual records without rewriting the entire file. Still, an index file would be a good idea, unless you maintain the flat file in some sort of sorted order so that you could perform binary searches on it when you need to find something.

All this is usually too much work. DBD::SQLite is really a convenient alternative, and nearly as compact as a flat-file approach, but without all the complexity. Honestly, you don't need to do this yourself, unless you're sitting in a comp sci class.


Dave


In reply to Re: To learn to search flat files or to cheat... by davido
in thread To learn to search flat files or to cheat... by stonecolddevin

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.