open(FH, "< $err_out") or die "can't open LOG FILE $!"; while () { $last = $_; } close FH; print "Last line was: ", $last; Alternatively you could just do this ad grab the whole file in an array: open FH, $file or die $!; @file = ; close FH; print "Last 4 lines, backwards: ", @file[-1,-2,-3,-4];