不過應該有比較簡易的寫法吧?目前是這樣比較容易閱讀 :p
filename = 'input.txt' output = 'output.txt' if File.file? filename p 'Reading File...' open(filename) do |f| open(output, 'a') do |out| p 'Writting File...' f.to_a.each do |x| if x =~ /String!/ out.puts x end end end # end of output end # end of filename else p "File Open Error!" end
http://pastie.org/238588
沒有留言:
張貼留言