アクセスカウンター
#! /usr/local/bin/perl # カウントの読み込み open(FILE, "+<./dat/count.dat"); eval{ flock(FILE, 2) }; $count = <FILE>; # カウントに1を加える ++$count; # カウントの書き込み seek(FILE, 0, 0); print FILE $count; close FILE; # HTML出力 print "Content-type: text/html\n\n"; print "<html>\n"; print "<head>\n"; print "<title>アクセスカウンター</title>\n"; print "</head>\n"; print "<body>\n"; print "<center>あなたは <b>$count</b> 人目の訪問者です</center>\n"; print "</body>\n"; print "</html>\n"; exit;
〔 実行する 〕