in reply to Find last line in Text file parsing

You're opening a file twice, that may not be necessary if you reconstruct your code to use the eof function to detect the end of the file, there is a difference between eof and eof() however and the later will only detect the end of the last file in a list of files provided whereas eof -without the parentheses- can detect the end of each file ...
use strict; use warnings; while(<DATA>){ if(eof){ #Check if the last line has ' last ' print ~/\slast\s/ ? 'yes' : 'no'; } } __DATA__ one line two lines three lines this is the last one

Excellence is an Endeavor of Persistence. A Year-Old Monk :D .