- 论坛徽章:
- 0
|
#! /usr/bin/perl -w
use strict;
my $reg = qr/=>/;
my @tmp = ();
my %hash = ();
my %dup = ();
open SRC, "<result.txt" or die "can not open file $!\n";
while(<SRC>){
chomp;
@tmp = split $reg;
if(not defined $hash{$tmp[1]}){
$hash{$tmp[1]} = $tmp[0];
}
else{
if(not defined $dup{$tmp[1]}){
$dup{$tmp[1]} = join ",", $hash{$tmp[1]}, $tmp[0];
}
else{
$dup{$tmp[1]} = join ",", $dup{$tmp[1]}, $tmp[0];
}
}
}
foreach (keys %dup) {
print join "=>$_\n", split(",", $dup{$_}), "\n";
}
close SRC; |
我写的,请各位高手指正 |
|