while() { ... } considered harmful continued ...

IlyaM on 2003-08-04T16:58:30

For background see this perlmonks node.

Seeing a recent patch at bug report #23141 makes me wonder if doing local $_; while(<>) { ... } will stop working too in general case. In other words if I get things correctly with this patch no CPAN module can use $_ even if it is localized because $_ may be readonly or have some magic attached to it and local will not remove it. Looks like using local with global variables is almost always bad idea unless callee can allow certain assuptions about callers (what is seldom a case for, say, CPAN modules).