in reply to Re: substituting values in an array
in thread substituting values in an array
Take notice of what Toby suggests here. Notice that there is no indexing going on, and that a change to a scalar variable (the built-in $_ in this case) effects a change in the value of the array element. The reason is that it is a reference to that element. The variable walks down the entire length of the array, and, because it is a reference to each value in turn, and not merely a copy of it, it can change it.
The somewhat “golf”-ish use of && is a “short-circuit” boolean-AND. If the expression on the left-hand side is True, the expression on the right-hand side is evaluated (and does something); otherwise it is not evaluated at all (since False AND anything is known to always be False).
This kind of “brevity of expression” is very common in Perl.