in reply to perl leaving out the last value?
This line (repeated twice with different identifiers):
while (chomp($symbol = <IN>))
... doesn't do what you want. chomp returns the total number of characters removed. Your last line has no line ending, so no characters are being removed. Since no characters are being removed, the return value of chomp, on the last iteration, is the moral equivelant of 'false'. Thus, the while() loop terminates without processing the last line.
Move the chomp inside the loop.
Additional reference on using the diamond operator: <>, truth and falsehood, and while loops. Also perfaq5. Three of those links provide examples of where to place the chomp.
Update: The documentation for chomp may actually contribute to confusion, since it shows both the correct placement within a while(){} loop, and also an example of how to chomp a single file-read outside of the context of a loop, in a way that would be inappropriate in a while loop.
Dave
|
|---|