Hello, On Fri, Aug 02, 2002, Shashank Date wrote: > I really like the convenience of doing: > > arr = IO.readlines("test1.txt") > > and then using [arr] to massage my data. > > But, when "test1.txt" is a big file (say 4MB) it takes for ever to read the > file. > > Is there any way to make it faster without sacrificing the terseness. on this file : oct@carafon:~$ ls -la sample.txt -rw-rw-rw- 1 oct oct 29445164 2002-07-09 11:05 sample.txt your version takes: oct@carafon:~$ time ruby read2.rb content is 233373 lines long real 0m5.434s user 0m3.770s sys 0m0.460s Using sysread is much faster than any other read i could experience in ruby. Then you can split this file using :split (although i'm not sure it is the fastest way to do that). Here are my results: oct@carafon:~$ cat read.rb input=File.open("sample.txt") all=input.sysread(File::size("sample.txt")) content=all.split("\n") print "content is "+content.length.to_s+" lines long\n" oct@carafon:~$ time ruby read.rb content is 233373 lines long real 0m1.938s user 0m1.130s sys 0m0.710s you can then easily wrap this inside a module and get your one-line program doing the readlines. hth, -- Pierre Baillet Il faut pomper pour vivre et donc vivre pour pomper. Devise Shadok