$_ was used by the loop, but it was no copy of the first array item, it was referencing it.
It was aliasing it.
Because something in the called CODE(0x9bcb9b0) was using $_
Perl has many global variables. If you're going to change them in a sub, you have to localize them.
sub foo { ... while (<$fh>) { # XXX Changes $_ ... } ... }
Fixed:
sub foo { ... local $_; while (<$fh>) { ... } ... }
In reply to Re: Magical data modification using $_
by ikegami
in thread Magical data modification using $_
by Sewi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |