From: Brian Candler Date: 2009-03-04T18:03:40+09:00 Subject: Re: implement "paste" using ruby Oliver wrote: > If I want to do it in Ruby, and number of files is a variable, and > each file itself can be potentially huge ... what would be the most > cost efficient way of implementing this? Assuming the number of files to paste together is reasonable (say under 1000), then I'd simply open all the files up front: files = ARGV.map { |fname| File.open(fname) } and then inside a loop use 'gets' to pick one line from each, and output those values together. HTH, Brian. -- Posted via http://www.ruby-forum.com/.