> 2000/03/29 (水) 04:57:14 ▼ ◇ [mirai]> テキストカウンタのソースキボン
#!/usr/local/bin/perl
$retry = 5;
$wait = 1;
$lockfile = './count.lock';
$countfile = './count.txt';
while(-f $lockfile) {
$retry--;
die if $retry <= 0;
sleep($wait);
}
open(LOCKFILE, ">$lockfile") or die;
close(LOCKFILE);
if(open(COUNTREAD, $countfile)) {
$count = <COUNTREAD>;
close(COUNTREAD);
} else {
$count = 0;
}
$count++;
open(COUNTWRITE, ">$countfile") or die;
print COUNTWRITE $count;
close(COUNTWRITE);
print $count;
unlink($lockfile);
exit;
参考:2000/03/29(水)04時49分46秒