作者: jzp520520 时间: 2014-01-10 16:18
#!/usr/bin/perl
use strict;
use warnings;
no strict 'refs';
#####将多个字典(dict1.txt dict2.txt)文件合并#####
open (my $fh1,"dict1.txt");
open (my $fh2,"dict2.txt");
open (my $fh3,">","newdict.txt");
my %h1;
while (<$fh1>) {
chomp;
my ($k,$v)=split /\s+/,$_,2;
push @{$h1{$k}},$v;
}
while (<$fh2>) {
chomp;
my ($k,$v)=split /\s+/,$_,2;
next if $v~~@{$h1{$k}};
push @{$h1{$k}},$v;