It removes the newline after the first assignment to $n prior to the loop, then unless the initial $n is 999, it'll step into the while(). You continue to remove the newline as each new STDIN is accepted, prior to the while() condition being checked again.
So effectively, inside the while, you chomp the input *before* the while is checked again. No chomp happens after the while, just the printing of the sum.
Does that help?
In reply to Re: confusion with Chomp
by stevieb
in thread confusion with Chomp
by Irishboy24
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |