http://qs1969.pair.com?node_id=169578


in reply to foreach loops

I think that it would be useful to point out that the loop variable is aliased to each element of the array in turn. It is not a copy of the element, so modifying the loop variable will modify the original array. One simple application of this is the initialisation of an array.
# Initialise an array so that $array[n] = n my $n = 0; foreach (@array) {$_ = $n++}