http://www.perlmonks.org?node_id=1199668


in reply to Splitting a file based on matched conditions

To read "the last line" of any file, seek() to a position relative to the end-of-file, that you know is far-enough back to encompass the last few lines, then start reading. (If the file might be UTF-8 then you need to be prepared to ignore UTF-8 errors on the off-chance that your seek put you smack in the middle of a multibyte sequence.) You really want to be sure that you read more-than-one line in this way so as to be very certain that the last line you read is complete.
  • Comment on Re: Splitting a file based on matched conditions