open ...; open ...; $/ = ''; while () { s/^\s+//; s/\s(?=\s)//g; print OUT; } #### perl -pe"BEGIN{$/=''} s/^\s+//; s/\s(?=\s)//g" test.txt > test.out