in reply to regex on previous lines

read lines reversed into an array

@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