in reply to Re: Answer: How do I copy out the last line written in a file?
in thread How do I copy out the last line written in a file?

When a file is read into an array the last element in the array array-1 would give you what you are looking for.

To put it more clearly, and in actual Perl rather than some pseudo-language, the first example above, i.e.

@array = <FILE>; $last_line = $array[$#array];

could be rewritten like

@array = <FILE>; $last_line = $array[-1];

or even without creating an intermediate @array:

my $last_line = (<FILE>)[-1];

Incidentally, I put a my in front of that as a reminder of the good rule of always staying strict.