use warnings; use strict; print "HEC1_ID,Q100_Base,TTP,Area\n"; while () { s{ ^ # at the beginning of the line \+ # followed by literal plus (?:\s+(\S+)) # column one (?:\s+(\S+)) # column two (?:\s+(\S+)) # column three (?:\s+\S+){3} # skip three columns \s+(\S+)$ # catch the last one, too }{$1,$2,$3,$4}x and print; } __DATA__ + BPI30 1319. 13.50 477. 147. 49. 4.64 ROUTED TO + RPI30 1220. 13.75 475. 147. 49. 4.64 HYDROGRAPH AT + BPI31 765. 12.42 102. 26. 9. .73 2 COMBINED AT + CPI31 1242. 13.75 571. 172. 58. 5.37