in reply to To learn to search flat files or to cheat...

In general, flat-files (which I take to mean CSV, and not XML or similar) are not the answer for data that you want to update and query. They are more useful for data exchange. When database systems were difficult to come by, they were more common as a backend. These days, there's not much reason to use them for storage on a new project. I suggest you use SQLite, or at least abstract them with BDB::CSV.
  • Comment on Re: To learn to search flat files or to cheat...

Replies are listed 'Best First'.
Re^2: To learn to search flat files or to cheat...
by Tanktalus (Canon) on Nov 09, 2006 at 22:17 UTC

    I actually use CSV for data store that I want to update and query. It offers me a fast way to manually update the file at the same time. Writing a program to run UPDATE TABLE WITH VALUE = 'foo' WHERE KEY = 'bar' when I can just go in with vi and tweak it ... just seems like a win to me ;-)

    (Not that I recommend this for all, or even many, uses ... especially live production ones, but you did say "there's not much reason to use them" - I think this one can be significant if it applies.)

    Update: perrin is right - I don't do this for CGI scripts, although I do use this in some statically-generated code whose data store isn't updated via code at all. I may move this to be dynamically generated at some point in the future, but the data store will likely remain read-only as far as the web app is concerned.

      You would edit a file with vi that can be modified by a live CGI? That's a recipe for lost data. You have to follow the same rules that the CGI script does for updating it if you want to be safe, i.e. set and respect locks.
Re^2: To learn to search flat files or to cheat...
by stonecolddevin (Parson) on Nov 09, 2006 at 19:01 UTC

    Thanks for the advice perrin. I'd say I'm still getting my wings with deciding what's best for data storage/query/etc. so this kind of advice helps put me in the right direction.

    meh.