From: Willem on
Matthew Horsfall wrote:
) It seems that while() loops don't localize $_ in certain situations,
) whereas for loops do.

For loops don't *localize* $_ either.
What they do is *alias* $_ to whatever they're looping on.

Try:
sub foo { print } for (<STDIN>) { foo }
As opposed to:
sub foo { print } my $_; for (<STDIN>) { foo }

) Is this expected behavior?

Yes. for() aliases whereas while() assigns.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT