in reply to Re: simple message board gone very wrong?
in thread simple message board gone very wrong?

At the top:

use Fcntl qw(:flock);

Immediately after the 'read open':

flock(FH, LOCK_SH);

Change the 'write open' to:

open(FH, "<+ $gb") or die "Could not open $gb: $!\n"; flock(FH, LOCK_EX); seek(FH,0,0); truncate(FH,0) or die "Could not truncate $gb: $!\n";

Once you use flock, make sure that every process that accesess the files also uses flock.

Also, the "local $/" should be in it's own block, otherwise anything else you add to the bottom of this script will be in "ultraslurp mode"