in reply to You can't assign $_ to a hash in a foreach statement
No.
For starters, a foreach loop never assigns to the variable. It makes it an alias to the value for that iteration.
And even if it did assign, the original value is restored at the end of the loop, so it would be of no use to you.
$_ = "abc"; say; for (qw( def ghi )) { say; } say;
Output:
abc def ghi abc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: You can't assign $_ to a hash in a foreach statement
by markdibley (Sexton) on Apr 08, 2022 at 17:03 UTC | |
by ikegami (Patriarch) on Apr 08, 2022 at 17:09 UTC |