CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Using IO::All with binmode


New User

Nov 5, 2009, 12:24 PM

Post #1 of 3 (985 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->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)


Nov 5, 2009, 11:40 PM

Post #2 of 3 (977 views)
Re: [delphipro9] Using IO::All with binmode [In reply to] Can't Post

According to the IO::All docs:

Configuration Methods

Proxy for binmode. Requires a layer to be passed. Use binary for plain binary mode.

So I would try:


(This post was edited by 7stud on Nov 6, 2009, 12:22 AM)

New User

Nov 6, 2009, 5:58 AM

Post #3 of 3 (967 views)
Re: [7stud] Using IO::All with binmode [In reply to] Can't Post

Thanks. I'll give that a try.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives