C:\test>type junk A B C D C:\test>perl -0pe"y/\n//s;s/(.+)\n(.+)/$1,$2/g" junk A,B C,D