lantern has asked for the wisdom of the Perl Monks concerning the following question:

Hey there,

I'm developing a CGI application on a Unix environment and started using flat files as my data store. Bad idea, obviously, because of the thread safety issue (if multiple CGI processes try to write to the same flat file at the same time ...).

So that got me wondering. Is there a way to make flat file data stores thread safe for CGI or is this an inherent problem that can only be solved using databases?

Thanks,
lantern

Replies are listed 'Best First'.
Re: Thread-safe cgi flat files
by borisz (Canon) on Feb 19, 2004 at 20:30 UTC
    Lock your file with flock or try DBI with DBD::SQLite it is a Database very simple to install.
    Boris
Re: Thread-safe cgi flat files
by Anonymous Monk on Feb 19, 2004 at 19:11 UTC

    Try flock or Fcntl