- 论坛徽章:
- 0
|
本帖最后由 懒狒狒 于 2012-12-05 15:36 编辑
open FILEINI,"Ip_Config.ini" or die "can't open conf file\n";
my @host;
while (my $line=<FILEINI>){
my ($ip,$addr)=split(/\s/,$line);
push @host,"$addr",if($ip eq "ip");
}
close(FILEINI);
这个是我得出@host 为需要过滤的数组
底下的方法是我现在可以求出的数组出现的次数
@rubyish
sub capinfo_ip{
#理论上要得出15条数据
my $temp_ip=$result_path."filter".strftime("%Y%m%d-%H%M",localtime(time)).".log";
open TEMP,'<',$temp_ip or die("No found this file$!");
my %hash;
while(<TEMP>){
chomp;
$hash{$_}++ if defined $hash{$_};
$hash{$_}=1 unless defined $hash{$_};
}
close TEMP;
exit;
open TEMP,'>',$temp_ip or die("No found this file$!");
print TEMP "SourthIP\tDestnationIP\tCounts\n";
print TEMP"$_\t","\t$hash{$_}\n" foreach((sort {$hash{$b}<=>$hash{$a}} (keys %hash)));
close TEMP;
} |
|