Nov 5, 2009, 12:24 PM
Post #1 of 3
Can someone enlighten me about how to use IO::All to create and output to a binary file. I can't get it to work at all.
Using IO::All with binmode
This should work:
my $fo = io('BinaryFile.bin', 'w');
$fo->print("This is a test\r\nThis is line 2\r\n");
The above code should create a file with single-spaced lines, as \r\n is a carriage-return linefeed in Windows. However, I get a double-spaced file. It seems to ignore the "binmode".
This does work (using IO::File instead):
my $fo = IO::File->new('>myfile.bin');
print $fo "Line 1\r\nLine 2\r\n";
Now I get a single-spaced file, as I would expect.
What's the deal? Does IO::All not work for binary files?
(This post was edited by delphipro9 on Nov 5, 2009, 12:25 PM)