foreach $line (@array) {
$count += s/\b$oldline\b/$spliced/eg for @array;
# ... more code here
}
Another point to consider with this block of code is that the
$count += s/\b$oldline\b/$spliced/eg for @array;
statement is executed for each and every element of the
foreach $line (@array) { ... }
loop, but unless something tricky is going on in the # ... more code here section, every execution of
$count += s/.../.../eg for @array;
after the first will have nothing to do: every substitution will have already been made on the first execution, i.e., with the processing of the very first element of the outer loop.
Give a man a fish: <%-{-{-{-<
In reply to Re^3: How to count substitutions on an array
by AnomalousMonk
in thread How to count substitutions on an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |