#!/usr/bin/perl

my($time , $ip , $host , $agent , $ref , $count , $data , $new , $last , $name);

chomp($time = `date`);
$ip = 		$ENV{'REMOTE_ADDR'};
$host = 	$ENV{'REMOTE_HOST'};
$agent = 	$ENV{'HTTP_USER_AGENT'};
$ref = 		$ENV{'HTTP_REFERER'};

open COUNT , 'count.dat' || die "Can't open count.dat";		#アクセス数記録ファイルオープン
$count = <COUNT>;
$count++;
close COUNT;
open COUNT , '>count.dat';
print COUNT $count;		#アクセス数記録
close COUNT;

open LOG , 'access.txt' || die "Can't open access.txt";
@_ = <LOG>;
close LOG;
@_ = sort {$b <=> $a} @_;



$data = "$count , $time ,  $ip , $host , $agent , $ref\n";
@_ = ($data , @_);

#100件以上は削除
if($#_ > 99)
{
	foreach (100 .. $#_)
	{
		$_[$_] = '';
	}
}

open LOG , '>access.txt';
print LOG @_;
close LOG;

