"Douglas J van Vliet" <dougie / global.co.za> writes:

> Is there a way of loading a text file in memory and then accessing the lines
> one at a time?

  # this opens, reads, and closes
  content = File.open("/etc/passwd") {|f| f.read}

  # this goes through it line at a time
  content.each do |line|
    puts line
  end

In Ruby 1.7, you can write the first step as

  content = File.read("/etc/passwd")


Dave