Subject: | missing binmode? |
Date: | Tue, 18 Sep 2007 20:01:53 +0200 |
To: | bug-File-Binary [...] rt.cpan.org |
From: | "Peter Möller" <peter.moller [...] gmail.com> |
Using File::Binary on winXP and Activestates Perl
Error - example
when doing
put_bytes($output . $c);
and $c happens to be a "\n".
what gets written to file is
$output . "\r\n"
Fix
do a binmode($fh) after $fh is creted in open.
-----------------------
sub open {
my ($self, $file) = @_;
my $fh;
my $writeable = -1;
if (ref($file) =~ /^IO::/ && $file->isa('IO::Handle')) {
$fh = $file;
$writeable = 2; # read and write mode
} else {
$fh = IO::File->new($file) || die "No such file $file\n";
if ($file =~ /^>/) {
$writeable = 1;
} elsif ($file =~ /^\+>/) {
$writeable=2;
}
binmode($fh); ## <<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
--
sigsigsigsigsagsigsigsigsig