- 论坛徽章:
- 307
|
- #!/usr/bin/perl
- use strict;
- use warnings;
- use utf8;
- use Encode qw(encode);
- my %hData = ();
- while(<DATA>){
- my @aT = split;
- if(!exists($hData{$aT[2]})){
- $hData{$aT[2]} = [@aT];
- next;
- }
- my $it = $hData{$aT[2]};
- foreach(grep {$aT[$_] !~/\A(0|nodata)\z/ and $it->[$_] eq 0} 0 .. $#aT){
- $it->[$_] = $aT[$_];
- }
- }
- print(encode('gb2312', join(" ", @{$hData{$_}})), "\n") for keys %hData;
- __DATA__
- 15-11-04 20:08:23 145998865 2345678 0 0 0 0
- 15-11-04 20:08:23 145998865 2345678 0 0 0 0
- 15-11-04 20:08:23 145998865 2345678 0 0 0 0
- 15-11-04 20:09:19 145998865 0 北京xx公司 0 0 0
- 15-11-04 20:09:19 145998865 0 北京xx公司 王二麻子+18512345678 0 0
- 15-11-04 20:09:21 145998865 0 北京xx公司 0 nodata 0
- 15-11-04 20:09:21 145998865 0 北京xx公司 0 0 0
- 15-11-04 20:09:21 145998865 0 北京xx公司 0 0 0
- 15-11-04 20:09:31 145998865 0 北京xx公司 0 0 0
- 15-11-04 20:09:31 145998865 0 北京xx公司 王二麻子+18512345678 0 0
- 15-11-04 20:09:32 145998865 0 北京xx公司 0 nodata 0
- 15-11-04 20:09:32 145998865 0 北京xx公司 0 0 0
- 15-11-04 20:09:32 145998865 0 北京xx公司 0 0 0
- 15-11-04 20:21:58 123466666 0 上海xx公司 0 0 0
- 15-11-04 20:21:58 123466666 0 上海xx公司 0 0 0
- 15-11-04 20:21:32 123466666 19003457 0 0 0 0
- 15-11-04 20:21:32 123466666 19003457 0 0 0 0
- 15-11-04 20:21:32 123466666 19003457 0 0 0 0
- 15-11-04 20:22:13 123466666 0 0 张三+13912345678 0 0
复制代码 |
|