in reply to Creating MIME entities with CRLF line endings

It sounds to me like you should keep binmode on at all time, so no automatic conversion, and convert "\n" to "\015\012" only in the headers, by hand. AFAIK, constantly swapping between binmode and text mode for a handle doesn't work well.

Note that

substr($string, $start, $length) =~ s/\n/\015\012/g;
should work fine. You only still have to locate the offsets/lengths of the substrings containing the headers.

Replies are listed 'Best First'.
Re^2: Creating MIME entities with CRLF line endings
by Anno (Deacon) on Mar 16, 2007 at 12:00 UTC
    ... locate the offsets/lengths of the substrings containing the headers.

    That, and account for the fact that the substitution may change the length of a header, and thus the offsets to subsequent headers. It's often easiest to reverse() the list of header locations and work your way backwards.

    Anno