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


in reply to Converting multiple lines into single line.

#!/usr/bin/perl # http://perlmonks.org/?node_id=1206966 use strict; use warnings; print join('', <DATA>) =~ s/^war \V* \K \{ .*? \}/ $& =~ tr|&\n||dr /e +gmsxr; __DATA__ some starting text war eligible, init =0*DEC0, ev (VARIABLE){1*BIN0,2*DEC3,6*BIN4, & 5*BIN43,6*DEC32, & 5*BIN43,7*DEC32} some other text war wear, init =1*DEC1, ev (VARIABLE) { & 1*BIN0,2*DEC3,6*BIN4, & 5*BIN43,6*DEC32, & 5*BIN43,7*DEC32,6*DEC32,6*DEC3, & 8*BIN3,6*DEC34 } some final text

Outputs:

some starting text war eligible, init =0*DEC0, ev (VARIABLE){1*BIN0,2*DEC3,6*BIN4, 5*BIN4 +3,6*DEC32, 5*BIN43,7*DEC32} some other text war wear, init =1*DEC1, ev (VARIABLE) { 1*BIN0,2*DEC3,6*BIN4, 5*BIN43, +6*DEC32, 5*BIN43,7*DEC32,6*DEC32,6*DEC3, 8*BIN3,6*DEC34} some final text