in reply to regex on previous lines

File::ReadBackwards might make things easier for you.