Re: Read File Into An Array


#1

I want to read a file into an array. I’m using the following code:

contentsArray = Array.new

f = File.open(“filenamehere”) or die “Unable to open file…”
contentsArray = filenamehere.each_line { |line| }

However, it seems to put the whole file into the array as one
item. If

IO.readlines(file)

Regards,

Dan

This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.