From: ara.t.howard@... Date: 2006-05-24T00:02:40+09:00 Subject: Re: Read File Into An Array On Tue, 23 May 2006, bc90141 wrote: > Hi, > > 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 > I try and use contentsArray.slice! I get: > > undefined method 'slice!' for # (NoMethodError) > > So it sees the contents of the array as a file instead of a list of text > lines as I want. > > What am I doing wrong? > > Thanks in advance. > > -- > Posted via http://www.ruby-forum.com/. array = IO.readlines pathname regards. -a -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama