Would this be a good way to lock a DBM file? The DBM file is not going to be for a counter, but I'm going to change it around so its for my memberpoints DBM file.
I'm soo confused about file locking. Does it mean you should lock a file because
visitors are going to click a button at the same time (ex. a logout button) that is going to make the PERL script to open the DBM file and write it at the same time and data would be lost?
or does it mean that
users on your server would open the DBM file (lets say in telnet or something) and edit and writes to the DBM file at the same time causing to lose data?
01: While(-f counter.lock){
02: select(undef,undef,undef,0.1);}
03: open(LOCKFILE,">counter.lock);
04: dbmopen(%COUNTERS, $DOCUMENT_ROOT/DBM_FILES/counters,0666);
05: if(!(defined($counters{'my_counter'})){
06: $counters{'my_counter'}=0;}
07: $counters{'my_counter'})++;
08: $count=$counters{'my_counter'};
09: dbmclose (counters);
10: close(LOCKFILE);
11: unlink(counter.lock);
Thank you,
Anthony