my $data = <<EOF;
    ...
    EOF

evidently deletes the <CR> characters.

As I understand it, in this particular case the CRs (carriage returns) are never there (in $data) to begin with. A here-doc is just another way to compose a string, in this case with double-quote interpolation (but that has no bearing here). Each line ends in a single  \n (newline) character.

Writing such a line to a Windoze "text"-mode (i.e., non-binmode-ed) file causes CRs to be added. This can be seen with an "ordinary" string containing newlines that is written in "text" mode and then read back binmode-ed:

c:\@Work\Perl\monks\Marshall>perl -wMstrict -e "use autodie; ;; use Data::Dump qw(dd); ;; my $s = qq{first\nsecond\n}; dd 's:', $s; print 'length: ', length $s, qq{\n}; ;; { open my $fh, '>', 'junque'; print $fh $s; close $fh; } ;; { open my $fh, '<', 'junque'; binmode $fh; my $t = do { local $/; <$fh>; }; dd 't:', $t; print 'length: ', length $t, qq{\n}; close $fh; } " ("s:", "first\nsecond\n") length: 13 ("t:", "first\r\nsecond\r\n") length: 15


Give a man a fish:  <%-{-{-{-<


In reply to Re^8: Error binmode() on unopened filehandle by AnomalousMonk
in thread Error binmode() on unopened filehandle by RedJeep

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.