in reply to Find last line in Text file parsing

For what value of 'best'? There are many ways that you could find the last line of a file. A good solution for one context may be bad in a different context. What are the interesting constraints for your application? For example:

  1. Do you know the maximum line length?
  2. Are the lines all the same length?
  3. Is the new line character consistent within the file
  4. Is the new line character consistent between files
  5. Is the file large (thousands of lines)?
  6. Does the task need to be performed many times a second?
  7. Does the code need to be written as baby Perl?
True laziness is hard work
  • Comment on Re: Find last line in Text file parsing