in reply to Re^2: How to count substitutions on an array
in thread How to count substitutions on an array
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: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to count substitutions on an array
by Anonymous Monk on Aug 13, 2016 at 19:11 UTC |