
delphipro9
New User
Nov 5, 2009, 12:24 PM
Post #1 of 3
(379 views)
|
|
Using IO::All with binmode
|
Can't Post
|
|
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. This should work: my $fo = io('BinaryFile.bin', 'w'); $fo->binmode(); $fo->print("This is a test\r\nThis is line 2\r\n"); $fo->close(); 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'); $fo->binmode(); print $fo "Line 1\r\nLine 2\r\n"; $fo->close(); 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)
|