Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Creating MIME entities with CRLF line endings

by rodion (Chaplain)
on Mar 16, 2007 at 09:29 UTC ( #605119=note: print w/replies, xml ) Need Help??

in reply to Creating MIME entities with CRLF line endings

Later Update: This is bad advice. See posts below by sgifford, bart and Anno.

Try using the ":crlf" directive with binmode() on the file handle, as in

binmode STDOUT, ':crlf'; $top->print(\*STDOUT); # or open MIME, '>', $fname; binmode MIME, ':crlf'; $top->print(\*MIME);
I think this will do what you want.


Thinking about it a little further, since MIME::Entity's print method takes a file handle as a parameter, it makes sense that it would leave control of line termination for the output file to the module that manages the output file handle, while using "\n" as the conventional line terminator within code. The binmode() function is Perl's way of controlling line termination on a file handle.

Replies are listed 'Best First'.
Re^2: Creating MIME entities with CRLF line endings
by sgifford (Prior) on Mar 16, 2007 at 14:20 UTC
    This converts binary parts too, which corrupts them if they contain the byte 0x0a.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://605119]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2021-09-24 09:36 GMT
Find Nodes?
    Voting Booth?

    No recent polls found