in reply to Safe Counter
$completeadd = "counter.txt"; open(MFILE, "$completeadd") || die "file open failed: $!\n"; flock(MFILE, LOCK_EX) || die "Lock failed: $!"; @filedata1=<MFILE>; chomp @filedata1; close(MFILE); if ($filedata1[0]) { $filedata1[0]=$filedata1[0] + 1; } else { $filedata1[0] = 1; } open(MFILE, ">$completeadd") || die "file open failed: $!\n"; flock(MFILE, LOCK_EX) || die "Lock failed: $!"; print MFILE "$filedata1[0]"; close(MFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Safe Counter Follow Up
by merlyn (Sage) on May 06, 2004 at 15:32 UTC | |
|
Re: Safe Counter Follow Up
by tachyon (Chancellor) on May 06, 2004 at 15:37 UTC | |
|
Re: Safe Counter Follow Up
by Ovid (Cardinal) on May 06, 2004 at 15:33 UTC | |
|
Re: Safe Counter Follow Up
by Ven'Tatsu (Deacon) on May 06, 2004 at 16:59 UTC | |
|
Re: Safe Counter Follow Up
by Anonymous Monk on May 06, 2004 at 21:07 UTC |