Hi PerlMonks, I've got a knotty problem with the MIME::Parser. When extracting a text-file attachment from an email it puts in extra ^M characters on Windows (expected behavior which is spoken of in the documentation).

My question is: is there a means of getting around this behavior, by manually tweaking a setting? Or if necessary, somewhere to tweak or subclass the code (not ideal given that I'm not *that* great with perl).

Example of the code I'm using (the email is already written to file - that section of code appears to be working perfectly given that I can extract .jpg and .csv attachments without problems):

... my $parser = new MIME::Parser; $parser->output_dir("unpacking"); $parser->parse_open("receiving/message-1.msg"); ...

When used with a .csv file it comes out perfectly. Rename the .csv file to a .txt file and resend, the extracted file has the extra ^M's on the end of each line.

Your thoughts and hints will be most appreciated.

Cheers!
William

PS: I'm using ActiveState's ActivePerl, version 5.16.3, built for MSWin32-x86-multi-thread. The binary build is: 1603 [296746].

PPS: In case it is relevant or you're interested, here is the appropriate MIME-part of the two saved message files:

(.csv) ------_=_NextPart_001_01CF26C0.66530897 Content-Type: application/x-msexcel; name="stuff.csv" Content-Transfer-Encoding: base64 Content-Description: stuff.csv Content-Disposition: attachment; filename="stuff.csv" YSxiLGMsZCxlDQphLGIsY2MsZGQsZWVlDQphYSxiYmIsY2NjYyxkZGRkZCxlZWVlZWUNCg +== ------_=_NextPart_001_01CF26C0.66530897--

...and...

(.txt) ------_=_NextPart_001_01CF26C0.A0C3FDAB Content-Type: text/plain; name="stuff.txt" Content-Transfer-Encoding: base64 Content-Description: stuff.txt Content-Disposition: attachment; filename="stuff.txt" YSxiLGMsZCxlDQphLGIsY2MsZGQsZWVlDQphYSxiYmIsY2NjYyxkZGRkZCxlZWVlZWUNCg +== ------_=_NextPart_001_01CF26C0.A0C3FDAB--

In reply to Is it possible to force MIME::Parser to extract text-files on a Windows system without the extra CR's on the end of lines? by WilliamDee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.