I installed File::Slurp and I can't reproduce your results. What do you get when you run the following? File::Slurp should remove carriage returns by default.

use strict; use warnings; use File::Slurp qw( read_file ); my $f = 'testdata'; { open(my $fh, '>', $f) or die $!; print $fh ("line1\n"); print $fh ("line2\n"); print $fh ("line3\n"); } { print("Disk size: "); print((stat($f))[7], "\n"); print("\n"); print("Inlined, binmode: "); print(length(do { local $/; open(my $fh, '<', $f) or die $!; binmode($fh); <$fh> }), "\n"); print("Slurp, binmode: "); print(length(read_file($f, binmode => 1)), "\n"); print("\n"); print("Inlined, not binmode: "); print(length(do { local $/; open(my $fh, '<', $f) or die $!; <$fh> }), "\n"); print("Slurp, not binmode: "); print(length(read_file($f, binmode => 0)), "\n"); print("\n"); print("Slurp: "); print(length(read_file($f)), "\n"); } print("\n"); print("\n"); { my $inline = do { local $/; open(my $fh, '<', $f) or die $!; <$fh> }; my $slurp = read_file($f); if ($inline eq $slurp) { print("Slurp is indentical to inlined version.\n"); } else { print("Slurp is different from inlined version.\n"); } }

You should get the following, exactly:

Disk size: 21 Inlined, binmode: 21 Slurp, binmode: 21 Inlined, not binmode: 18 Slurp, not binmode: 18 Slurp: 18 Slurp is indentical to inlined version.

Environment:

>perl -MFile::Slurp -le "print $File::Slurp::VERSION" 9999.09 >perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) ...

In reply to Re^2: File::Slurp bug? Should I bother? by ikegami
in thread File::Slurp bug? Should I bother? by chester

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.