OK, I have the following code:
use strict; my @ar = (1, 2, 3); foreach my $a (@ar) { $a = $a + 1; } print join \", \", @ar;
and the outp
$a in this case is an alias to the array element. Just don't have $a = in your code and you won't modify the array. :-)
$a
$a =
If I remember correctly, map, grep, etc. all have the same aliasing behaviour.
map
grep