in reply to Re: (MeowChow) Re2: When does $_ get used?
in thread When does $_ get used?

while is, in my opinion, generally waaaay over-used. foreach generally does everything you want in a while, and more (like assigning to $_). If you want to treat @list like a filehandle, then do a foreach(@list).

As a sidenote, you can also do something like:

foreach (<>) { # Do something with $line here... }
What that does is require that all the input be done, then release the output. This is unlike while (<>), which will pass its value through to the loop immediately. The difference is because foreach needs to know when it ends, while while doesn't care and will keep going until it's given a false value.