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


in reply to Display last record

Just move the file pointer to the end of the file minus whatever the maximum record size is, then read everything to the end of the file and extract the last record. This should be quite efficient even with huge files.

Replies are listed 'Best First'.
Re^2: Display last record
by Happy-the-monk (Canon) on Dec 31, 2005 at 18:43 UTC

    Just move the file pointer to the end of the file minus whatever the maximum record size is, then read everything

    Without example code to back it up, this must look quite a bit obscure to a newbee.

    Being concerned of large files I would opt for the answer in perlfaq5 to perldoc -q "a line in a file" and use Tie::File.

    Cheers, Sören