http://www.perlmonks.org?node_id=849332


in reply to Re^5: Join lines that match an string
in thread Join lines that match an string

What really isn't clear in the OP is whether you want to keep the lines you don't join in the output or throw those lines away. This isn't even clear from your detailed description, though in your code you throw them away. I assumed the OP wanted to keep those lines and only change the joined lines.