for my $i(0..$#test1){ if($test1[$i] == 0){ $test1[$i] = $test2[$i]; } }