in reply to Flock Updating Counter
You should simplify your code to only open the counter once. Otherwise you have a race condition.
open FH, "+< counter.dat" or die $!; flock(FH, 2); $id = <FH>; $id++; seek(FH, 0, 0); truncate(FH, 0); print FH $id or die $!; close FH or die $!;
It would be more elegant to use a database with an autoincrementing key.
After Compline,
Zaxo
|
|---|