From: "Peña, Botp" Date: 2007-06-28T11:25:34+09:00 Subject: Re: Is there a nifty ruby hack for this set of commands? On Behalf Of Frank Church: # f = File.new(configfile, File::CREAT|File::WRONLY, 0700) i'd prefer to you use the block mode # header_commands.each {|x| f.puts x } # mysql_commands.each {|x| f.puts x } # dir_commands.each {|x| f.puts x } # scp_commands.each {|x| f.puts x } # # Is there a way to do something like # # [header_commands, mysql_commands, dir_commands, scp_commands] # each {|x| # f.puts x } assumming x_commands are arrays, read on array#:+ or array#flatten. but you can still stick to your original algo and since it's just an array of arrays, you just nest like, m_list = [] # ---------------------------------------- m_list << header_commands # the adv here is that i can put comments m_list << mysql_commands # and can rearrange/preprocess commands m_list << dir_commands # without touching the main/meat loop code m_list << scp_commands # ---------------------------------------- m_list.each do |cmdlist| cmdlist.each do |x| f.puts x end end if you want to be fancy, try yaml so you can save/restore the command groups anytime. even rio will tickle your fancy, rio("a.txt") << m_list.join("\n") # I know there must be a number of ruby ways to do it. you bet. watch this thread :) kind regards -botp