in reply to Re^4: Breaking String
in thread Breaking String

Nope... there are several things wrong with your code.

First, you're not truncating the string. You're only wrapping the original first two lines. You likely forgot a trailing (?s:.*) after the part you capture. Still, I very much dislike the idea of using s/// to delete the bulk of a string. That's a very inefficient way to do it.

And second, even if you got rid of everything after those lines, you still may end up with more than 2 lines. You see, Text::Wrap will not unwrap existing newlines, but instead, it may add more newlines, if the runlength of the line is too long. You'll always end up with at least as many lines as you started from. So if you start out with 2 lines, you still may end up with 5...