in reply to regex on previous lines
@lines=reverse <$fh>
or
@lines=reverse split /\n/, $multiline
Now you can loop over @lines and exit with last whenever a regex fails.
Cheers Rolf