Ezra Zygmuntowicz
1/9/2006 5:54:00 PM
On Jan 9, 2006, at 9:44 AM, Victor Reyes wrote:
> Team,
>
> ruby -v === ruby 1.8.2 (2004-12-25) [powerpc-aix4.3.3.0]
>
> Please don't laugh at my simplistic coding "techniques?"
>
>
> I am reading a file which contains 1041 one token records into an
> array:
>
> f_lus = File.open("/file_name", "r")
>
> lus = Array.new
> lus = File.read("/file_name")
Right here you are createing a new arrau called lus. then you destroy
it and overwrite it with a file handle. Please try this instead:
ezra:~ ez$ cat test.txt
12
324
46
23
dgs
fh
asf
fh
dsg
lus = File.open("test.txt") {|f| f.readlines}
p lus
#=> ["12\n", "324\n", "46\n", "23\n", "dgs\n", "fh\n", "asf\n", "fh
\n", "dsg\n"]
Cheers-
Ezra