From: Tim Kynerd Date: 2003-02-13T01:23:52+09:00 Subject: Re: String frustration On Wed, 12 Feb 2003 19:37:35 +0900, Hugh Sasse Staff Elec Eng wrote: > On Wed, 12 Feb 2003, Tim Kynerd wrote: > >> On Wed, 12 Feb 2003 14:16:03 +0900, Harry Ohlsen wrote: >> >> >> The input file contains three tab-separated fields. The second field >> needs to be able to contain an arbitrary number of newlines (which will >> be realized as actual newlines, so to speak, when this field is later >> printed out). >> > [...] >> Then, since there happen to be exactly three fields in each line, >> there's the idea of tab-separating the "pieces" of the second field, >> then reading >> > irb(main):044:0> puts (sprintf "%s", "x\ny") x > y > nil > irb(main):045:0> > > so readlines.each {|line| > fields = line.split(/\t/); > fields.each {|field| > puts (sprintf "%s", field) > } > } So using readlines rather than gets is the key. OK, that makes things easier. Thanks! -- Tim Kynerd Sundbyberg (sm�stan i storstan), Sweden tim@tram.nu Sunrise in Stockholm today: 7:39 Sunset in Stockholm today: 16:24 My rail transit photos at http://www.kynerd.nu