in reply to Grab last line and print

ad 1) If you want to get the last element of an array you can use the index -1 or $#array_name: print $lines[-1]; or print $lines[$#lines];

ad 2) if you are only interested in the last line you don't need to store the whole file in an array. Just loop through the file and remember the line you've just read, until you arrive at the end and print the last line you've seen.

Of course if you know the file is huge you may need/want to do something more complex, using seek(), reading last N bytes of the file, checking there is a newline character in that and possibly read a bigger chunk ... but the question is whether it's worth the effort.