From: Robert Klemme Date: 2006-03-14T01:38:55+09:00 Subject: Re: Recursive line counter (review?) ChrisH wrote: > I like your use of inject. However, the code you show is not > recursive, but thats not really important unless it being recursive > was the point... > > When I was playing with a similar bit of code I recall using > > IO.readlines('filename').size > This doesn't work well with large files and also uses more resources (memory). > I also recall trying > > f=File.open('filename') > f.seek(0,IO::SEEKEND) > lc = f.lineno > Does this really work? I can't believe it because during seeking the file is actually not read - so the IO instance cannot really count line numbers, can it? > If speed is an issue oyu might want to compare various methods. Yeah. Kind regards robert