From: Toki Toki Date: 2008-08-17T20:09:45+09:00 Subject: Re: String manipulation: cut, insert, column editing... Eric I. wrote: > Here's some Ruby code that may do what you're interested in: > > ==== > > d1 = open("f1.txt") do |f| > f.readlines.map { |line| line.chomp } > end > > d2 = open("f2.txt") do |f| > f.readlines.map { |line| line.chomp } > end > > d3 = [d1, d2].transpose > > p d1, d2, d3 # just so you can see what's happened so > far > > d3.each do |str1, str2| > puts "This is the #{str1} (#{str2}) item." > end > > ==== > > That's assuming f1.txt contains "first", "second", etc., one per line > and that f2.txt contains "1st", "2nd", etc., one per line. > > Eric > > ==== Thanks a lot for the code, it works great and it's really clear. Best regards. -- Posted via http://www.ruby-forum.com/.