為了從Apache的access_log來統計每天每個小時的網站瀏覽次數,以下簡單的PERL 程式可以幫助各位取得大概的數字。
#!/usr/bin/perl -w
open ( FH, "../../access_log.1" );
while ()
{
chomp;
$_ =~ s/^.*?:(\d{2}):.*/$1/;
$hr{$_}++;
}
close( FH );
foreach ( sort keys %hr )
{
print "Hour $_ has $hr{$_} times access.\n";
}
--
#!/usr/bin/perl -w
open ( FH, "../../access_log.1" );
while (
{
chomp;
$_ =~ s/^.*?:(\d{2}):.*/$1/;
$hr{$_}++;
}
close( FH );
foreach ( sort keys %hr )
{
print "Hour $_ has $hr{$_} times access.\n";
}
--
沒有留言:
張貼留言