in reply to Re^2: Foreach Loop Optimization
in thread Foreach Loop Optimization
I don't think changing $_ is dangerous. The perdoc does it a lot.
Sometimes it won't cause any problems. Sometime it creates hard to debug action-at-a-distance problems because it's common for code to rely on $_ being left unchanged by the functions it calls.
If you modify $_, localize it. Of course, local $_ = $val; is buggy so local *_ = \$val; or for ($val) should be used instead. Or better yet, just don't assign to $_.
In this particular case, the only thing the assignment to $_ does is obfuscate, so it's a bad idea regardless of all the problems and complexity I just mentioned.
For some reason, I was thinking =~ would change the value of $headers[$dataCount].
All =~ does is specify the operand for the following (m//, s///, tr///, etc) operator.
|
---|