tie *FILE, File::ReadBackwards 'input_file'; while () { # line-by-line starting from the end }