----- Command Infomation ----- argc is 1 argv is counter02.cgi ----- Script Infomation of counter02.cgi----- #!/usr/local/bin/perl5 # ロック制御付きイメージカウンタ # by Naotoshi Haraguchi # 2001/03/07 Last modefied unshift(@INC, "."); require "util.pl"; $cntfile = "./counter02.dat"; #カウンタファイル名 #カウンタファイルが無ければ初期ファイルを作成 if(! -f $cntfile){ open(CNT, "> $cntfile") || &exitERR("counter01.cgi: $cntfile を作成出来ません。"); print CNT "0"; close(CNT); } #カウンタファイルへのアクセス &lockopen(CNT, "+< $cntfile") || &exitERR("counter01.cgi: $cntfile をロックオープン出来ません。"); $cnt = ; $cnt++; seek(CNT,0,0); print CNT "$cnt"; &unlockclose(CNT,$cntfile); #カウンタの数値を一桁ずつ分割し桁数を算出 @num = split(//, $cnt); $size = @num; #桁あふれの場合は99999を設定 if($size > 5){ @num = ("9", "9", "9", "9", "9"); } #0パディング for($i=$size; $i < 5; $i++){ unshift(@num, "0"); } #カウンタの表示 while(){ s/__5__/$num[0]/g; #万の位 s/__4__/$num[1]/g; #千の位 s/__3__/$num[2]/g; #百の位 s/__2__/$num[3]/g; #十の位 s/__1__/$num[4]/g; #一の位 print; } exit(0); __END__ Content-type: text/html アクセスカウンタ
あなたは __5__ __4__ __3__ __2__ __1__ 人目のお客様です。