in reply to Regexp vars localization in blocks
In a while loop, there is a per-pass scope that extends beyond the body. The loop expression is evaluated in this scope.
In a foreach loop, you also have a per-pass scope that extends beyond the body of the loop. The loop iterator var is found in this scope.
While a C-style for loop has a statement-wide scope, doesn't have a per-pass scope beyond the loop body.
map and bare loops similarly don't have a per-pass scope beyond the loop body.
I don't know much about $& localization, but the results correlate to the existence of that larger per-loop scope.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regexp vars localization in blocks
by Anonymous Monk on Jul 28, 2023 at 20:55 UTC |