{ local $_; print while (shift @list); }
This doesn't work, because $_ is never assigned to. I think you took it from this example code:
{ local $_; while(<>){ print; } }
This works because the assignment to $_ is taken care of by using angle brackets alone inside the while. I think you meant:{ local $_; print while ($_ = shift @list); }
--In reply to Re: Answer: How do I localize $_ in while loops?
by edan
in thread How do I localize $_ in while loops?
by ajdelore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |