$line = 'Iteration {Applied Field} {Total Energy} Mx '; print "$1\n" while $line=~s/(\w+\s+\w+|\w+)[}|\s+|\s+{]//; Iteration Applied Field Total Energy Mx