naPOLeon
10/27/2006 1:44:00 PM
I would do this that way:
var = Array.new
File.open("file.txt", "r") do |file|
file.each_line do |line|
var << line.split
end
end
Now you have an array to play with.
If you want to access a specific line, use
sth = var[0] => ["Peter", "4", 1990"]
Or a single variable:
var[0][0] => "Peter"
var[2][2] => "1991"
If you want to write them into an other file, just write:
File.open("write.txt", "a+") do |file|
file << var
end
Hope thats, what you were looking for,
naPOLeon