#!/usr/bin/perl # ログファイル名を指定 $log = "counter.dat"; print "Content-type: text/html\n\n"; open(IN,"$log"); flock(IN, 1); $count = ; close(IN); print $count; ✓ sub check { @hosts = ('sony.co.jp','Sony.CO.JP'); $host = gethostbyaddr(pack("C4", split(/\./, $ENV{'REMOTE_ADDR'})), 2) || $ENV{'REMOTE_ADDR'}; foreach $i (@hosts) { if ($host =~ /$i/) { open(IN,"$log"); flock(IN, 1); $count = ; close(IN); $count++; open(OUT,"> $log"); flock(OUT, 2); print OUT $count; close(OUT); exit; } } }