Hello
I'm learning Perl and have a very basic question about a code snippet I don't understand in the book I'm reading. Here is the code
This is simply reading in from a filehandle previously created. There is no context in the book given about this bit of code. I think the books assumes it is self-explanatory.
I don't understand the ' $total' line. I thought the $_ variable would contain a line of input from the filehandle in each round of the loop. If this input was text and was evaluated in a scalar context it would be converted to 0 and so the total would always be 0? I think this code could make sense though if each line of input in the file was a number.
I appreciate this is a very basic question but I would like to check I understand what is going on. I have no other peers to ask.
thanks