From: Ted Flethuseo Date: 2010-06-25T13:30:32+09:00 Subject: writing binary file Hi everyone, I'm trying to write a couple of numbers to a binary file: num = [1234567, 30, 40] File.open("test.file", "wb") { |f| num.each { |e| f.write e.to_i.pack("I") } # f.write num.pack("I") } a = [] File.open("test.file", "rb") { |f| a = f.read(4).unpack("I") puts a } but I get errors for pack, I'd like to be able to use it such that I can read write several integers to binary file. I have seen it work for this code (but it is only one int): num = [1234567] File.open("test.file", "wb") { |f| num.each { |e| f.write e.to_i.pack("I") } # f.write num.pack("I") } a = [] File.open("test.file", "rb") { |f| a = f.read(4).unpack("I") puts a } Any help appreciated. Ted -- Posted via http://www.ruby-forum.com/.