in reply to Internally, how do for() and while() differ?

I think you also want to be careful about the truthiness of your input values with while. See defined for an approach.

Update: Hmm, after testing, I am not sure on this advice. Possibly ignore me.

Update 2: confirmed -

while (<>) {...} ... is Perl shorthand for the more explicitly written ... while (defined($line = <ARGV>)) {...}

--MidLifeXis