From: Dark Ambient Date: 2006-07-07T01:17:17+09:00 Subject: Re: Question: formatting strings from array for text files I must have not explained myself well. Right now my file looks like this: c:/dir1/doc1.docc;/dir1/doc3.docc:/dir1/doc4.docc:/dir1/doc5.doc ..........i.e. no line breaks I want it took look like this: c:/dir1/doc1.doc c;/dir1/doc3.doc c:/dir1/doc4.doc c:/dir1/doc5.doc .......... Stuart On 7/6/06, Robert Klemme wrote: > 2006/7/6, Dark Ambient : > > I'm not sure who to have an array format correctly when written to a text file. > > What does "correctly" mean? > > > Doing something like myarray = ['five','four','three','two','one'] > > works almost correctly but > > myarray = ['.././*.docs'] seems to write them out without linebreaks. > > This is not a print statement. What did you do to actually print it? > > > So while I can figure out how to print them nicely using some iterator > > to the screen > > Using, > > File.open filename, 'w' do |doc| > > doc.write myarray > > end > > I can't seem to figure out a way to format the strings correctly. > > Try this: > > doc.write myarray.join ", " > > Depends on what you mean by "proper output". > > Kind regards > > robert > > -- > Have a look: http://www.flickr.com/photos/fussel-foto/ > >