Hi! This seems to be quite repetitive but I still cannot figure out how to solve this...

I'm using Email::MIME::CreateHTML to build an email that contents an HTML message with a PNG image that I want to include in the email encoded as BASE64. Everything seems to work OK except for the fact that in the email, when displayed by the recipient's email client, the image is broken. I've decoded the BASE64 part of the multipart body and found that the encoded file had 1 byte less that the original image file. So I binary compared the original and decoded files and found that the missing byte was because read_file in File::Slurp always does a CR/LF into NL substitution with the asumption that it is a text file just because I'm running in a Windows machine ($buf =~ s/\015\012/\n/g if $is_win32 ;), and this binary image just happens to have that sequence of bytes in it's header.

Is there a way to replace the read_file method, without editing the modules or rewriting a whole resolver, or to force it to use binmode? Well, Slurp accepts some options like binmode, but this obvously needs CreateHTML to send that option to it, and I'm not sure if that works with small binary files.

Thanks!


In reply to How to bypass File::Slurp when it is required by another module? by vitoco

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.