2 つの MySQL テーブルを同期するために使用している次の手順があります。
sub sync{
my %tables = (
'sitematrix_test' => 'sitematrix_sites'
);
while(($key, $value) = each(%tables)){
print "Matching columns $key : $value\n";
my @data;
my $query = $db->prepare("
SELECT $key.* FROM $key LEFT JOIN $value ON
$key.site_id = $value.site_id WHERE $value.site_id IS NULL;
")
or die "Couldn't prepare statement: " . $db->errstr;
$query->execute()
or die "Couldn't execute statement: " . $query->errstr;
if($query->rows == 0){
print "No updates have been made for $key : $value";
}
else{
#read the matching records and print them out
while(@data = $query->fetchrow_array()){
print "@data\n";
}
}
$query->finish;
}
$db->disconnect;
}
次のエラーが発生します。
Use of uninitialized value $data[3] in join or string at C:/Users/souzamor/workspace/Parser/synchronizer.pl line 69.
Use of uninitialized value $data[4] in join or string at C:/Users/souzamor/workspace/Parser/synchronizer.pl line 69.
Use of uninitialized value $data[5] in join or string at C:/Users/souzamor/workspace/Parser/synchronizer.pl line 69.
Use of uninitialized value $data[6] in join or string at C:/Users/souzamor/workspace/Parser/synchronizer.pl line 69.
なぜ配列の境界を超えているのか、誰か説明してもらえますか?