WilliamDee has asked for the wisdom of the Perl Monks concerning the following question:
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--
|
|---|