From: Brian Candler Date: 2003-04-27T19:35:37+09:00 Subject: Re: File reading and line continuation with '\' > > > cat a > > one\ > > two > > irb(main):001:0> a=File.read("a") > > => "one\\\ntwo\n" > > irb(main):002:0> b=File.readlines("a") > > => ["one\\\n", "two\n"] > > > > I would like instead: > > > > f=File.readlines("a") > > ["onetwo\n"] Alternative solution: how about joining the adjacent strings together in-place after reading them in? lastline = "" a.delete_if do |line| if lastline.gsub!(/\\\n\z/,line) true else lastline = line false end end which can be even further obfuscated to: lastline = "" a.delete_if do |line| lastline.gsub!(/\\\n\z/,line) or not lastline = line end # before: a=["one\n", "two\\\n", "three\\\n", "four\n", "five\n"] # after: a=["one\n", "twothreefour\n", "five\n"] Regards, Brian.