in reply to Updating 1 array affects the other array

I think your problem seems not being caused by the code you show us. It is probably caused in the construction the arrays. You might have used the method below:
$array2[$n] = $array1[$n];
Because your two arrays are complex, this does not copy the structure and content, but only copy the corresponding reference. So the value $n in @array2 actually points to the value $n in @array1.
In addition, while asking questions, please make your code more refined, for example:
for my $i (0..$#array1) { for my $j (0..$#array2) { # do something } }