Reputation: 375
Lets say I have the following:
#!/usr/bin/perl
use strict;
use warnings;
use CGI ":standard";
...Snippet...
open (FH, '>', "file.txt") or die ("ERROR:$!");
print FH "something";
close(FH);
As it it cgi on Apache, this cgi script could be called concurrently.
What happens if I wanted conditional logic...
I am investigating utilizing lsof for setting up synchronous file locking, but do not want to go down bad path. (Might be better off using SQL).
Upvotes: 1
Views: 101
Reputation: 69224
Yes, you should almost certainly use a database for this.
If there's some reason why you really don't want to use a database, then at least use the file locking mechanisms that already exist and don't invent your own. There are plenty of questions (and answers) about this in perlfaq5.
Upvotes: 1