http://qs321.pair.com?node_id=849324


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

But I still have the feeling I didn't get the whole idea correctly; especially when I see ambrus' solution.

If you want to keep the linebreak in the "p_agrs" line, then tell perl not to chomp it.

Example:

perl -wpe 'if ( m/\bremotely\b/ ... m/\bp_agrs\b/ ) { chomp unless m/\bp_agrs\b/ }'