as the expression is non-greedy, but instead I get nothing. I realize this is because it encounters the s and matches the least to the next e p. So I can evaluate each match and deal with it there, but I was wondering if there was a better way to accomplish this.
Update: fixed the data space and added more information to the testcase.

==
Kwyjibo. A big, dumb, balding North American ape. With no chin.

Comment on Matching and replacing the minimum string from the tail of the regex

Don't tell us what you think the code does. Tell us what you want to achieve and why.

You've told us what output you expect for a given input, but not how the output is relate to the input. We can't tell that from your code because your code doesn't do what you want, nor even what you describe! The actual output is:

My apologizes, I missed the final line of the data space. What I'm trying to do is eliminate pass messages from a build log while keeping all the failure text. Each test has a start and end, but some data can be shown after a failure. I will update the code to reflect this. That said, I only want to eliminate items between the start (s) and the end which passed (e p).

If your data set is small, and I guess it is as you are reading all of your lines into a single string, you could use grep to just get the lines that match a regex alternation of what you want then use another grep with a post-incremented hash so that you only get the one 's' line rather than all three.

which changes the default input record separator inside the scope of the code block to undef so that the whole of the file is read into $lines in one fell swoop.

I hope this is of use.

Cheers,

JohnGG

Update: I should have placed the regex alternation in a non-capturing group. As it is, it matches lines beginning with 's', lines containing 'foo' anywhere and lines ending with 'e f'. Correct pattern is m{^(?:s|foo|e f)$}.