服务器表检测数据的一致性

my $table_name1 = shift;#表
my $data211 = shift;#服务器1上表的数据
my $data12 = shift;#服务器2上表的数据

my %hash1;
my %hash2;
my $search_difference1;
my $search_difference2;

for(my $i=0;$i<scalar(@$data12);$i++){
my $hash_one = $data12->[$i];
my $str = "";

for my $d12(sort keys %$hash_one){
if(!defined $hash_one->{$d12}){
$hash_one->{$d12} = "";
}
$str .= $hash_one->{$d12}."##";
}
$hash1{$str} = 1;
}

for(my $j=0;$j<scalar(@$data211);$j++){
my $hash_one1 = $data211->[$j];
my $str1 = "";
for my $d211(sort keys %$hash_one1){
if(!defined $hash_one1->{$d211}){
$hash_one1->{$d211} = "";
}
$str1 .= $hash_one1->{$d211}."##";
}
$hash2{$str1} = 1;
}
foreach(keys %hash1){
if(exists $hash2{$_}){
}else{
Encode::from_to($_,'utf8','gb2312');
print MYTXT "服务器1上$table_name1表不存在:$_的数据\n";
}
}
foreach(keys %hash2){
if(exists $hash1{$_}){
}else{
Encode::from_to($_,'utf8','gb2312');
print MYTXT "服务器2上$table_name1表不存在:$_的数据\n";
}
}

你可能感兴趣的:(J#)