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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |