in reply to Grab last line and print

Since you already have the contents of the file stored in an array:
print "here is last line: $lines[ -1 ]";