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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |