- 论坛徽章:
- 0
|
本帖最后由 下后下前拳 于 2010-11-15 16:02 编辑
日志的格式如下:
58.20.46.212 - - [15/Nov/2010:15:24:11] "GET /announce?info_hash=5%de0%23d%d3%24%04%83%c0q%fe%5dj%eb%beK%3f%7b%0d&peer_id=-QD1900JAjDdcr527bDL&port=80&uploaded=22620764&downloaded=1184644876&left=6872891392&key=b285cead&compact=1&numwant=200&no_peer_id=1 HTTP/1.0" 200 46 "-" "qqdownload/1.9.273.0"
代码如下:
#!/usr/bin/perl
use warnings;
use strict;
my $day=`date -d 'yesterday' +%d/%b`;
print $day;
my $file="/var/log/bt.log";
my $i=0;
my @line;
my %ip;
open(BT,$file);
my @array=<BT>;
close(BT);
foreach(@array){
@line=split(' ',$_);
if ($line[3]=~/^\[$day/ && $line[7]==200){
$ip{$line[0]}=1;
}
}
foreach (keys %ip){
$i++;
}
print $i."\n";
总是报错。。Use of uninitialized value in pattern match (m//) at ./bt_calculate.pl line 18.
弄了半天都是这个问题。。疯了 |
|