|
发表于 2011-7-1 17:18:50
|
显示全部楼层
#!usr/bin/perl
open (fp,"file.txt");# file.txt 保存你需要处理的数据
open (fp_out,">file_out.txt");#file_out.txt保存处理后的结果
seek (fp,0,0);
while(<fp>)
{
chomp($_);
s/^\s+|\s+$//g;
my($blk1,$blk2,$blk3)= /(\S+)\s+(\S+)\s+(\S+)/;
if($my_hash{$blk1} <= $blk3) #undef can be treated as 0
{
$my_hash{$blk1} = $blk3;
}
}
while(($key,$value) = each %my_hash)
{
print fp_out "$key $blk2 $value\n";
}
close(fp);
close(fp_out); |
|