|
Posted by Jürgen Exner on April 19, 2008, 6:08 am
Please log in for more thread options >PerlFAQ Server wrote:
>[...]
>> 5.3: How do I count the number of lines in a file?
>>
>>
>> One fairly efficient way is to count newlines in the file. The
>> following program uses a feature of tr///, as documented in
>> perlop. If your text file doesn't end with a newline, then it's
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Shouldn't this be "If the lines in your text file do not end with a
>newline", or something to that effect?
No. It is a different way of saying "If there is stuff after the last
newline then that stuff doesn't constitute a proper line..."
>A text file need not have a "\n"
>at the very end :)
>
>> not really a proper text file, so this may report one fewer line
>> than you expect.
"... and therefore it is not be counted as a line."
jue
|