Did you consider to leave \n's of MIME:: as they are, collect whatever MIME:: outputs, and manually replace \n's to CRLFs? If you should adopt this method, you will have to maintain a clean division line, which scalars contain newlines encoded as CRLF, and which contain system-specific newlines. The conversion between these is trivial, s/\n/\xD\xA/g unless "\n" eq "\xD\xA" and vice versa.