Hi everyone, I have the following chunk of code:
foreach $G (@array1){ for $x (0..$#array2){ if($array2[$x] =~ /$G/){ push(@Coordinates,"$array2[$x]"); } } }
I would expect this to create the array "Coordinates" with every value of array2 that matches array1, but what ends up happening is that the array only contains one value, the last value of array1--which indicates that it gets continuously replaced. How can I fix this?
In reply to Why does every value of the array get replaced? by andybshaker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |