File.puts define newline

Hi,

just would like to know if I can somehow define the newline delimeter
when using file.puts ?
e.g. /n, /r/n

Thanks a lot in advance…

[email protected] schrieb:

Hi,

just would like to know if I can somehow define the newline delimeter
when using file.puts ?
e.g. /n, /r/n

Thanks a lot in advance…

hm…I don’t think so.
Can’t you use file.print and append a “\r\n” or whatever you need?

On 9 Feb., 14:50, badboy [email protected] wrote:

[email protected] schrieb:> Hi,

just would like to know if I can somehow define the newline delimeter
when using file.puts ?
e.g. /n, /r/n

Thanks a lot in advance…

hm…I don’t think so.
Can’t you use file.print and append a “\r\n” or whatever you need?

Sure I can do that, but I thought it would be “cleaner” if I could to
something like:
file = new File…
file.newline_delimiter = ‘/r/n’
or
file.newline_delimiter = ‘dos’

[email protected] wrote:

On 9 Feb., 14:50, badboy [email protected] wrote:

[email protected] schrieb:> Hi,

just would like to know if I can somehow define the newline delimeter
when using file.puts ?
e.g. /n, /r/n

Thanks a lot in advance…

hm…I don’t think so.
Can’t you use file.print and append a “\r\n” or whatever you need?

Sure I can do that, but I thought it would be “cleaner” if I could to
something like:
file = new File…
file.newline_delimiter = ‘/r/n’
or
file.newline_delimiter = ‘dos’

You are supposed to be able to do this:

$OUTPUT_RECORD_SEPARATOR = “apple”

f = File.open(“data.txt”, “w”)
f.write “hello world”
f.write “goodbye”
f.close()

but the output I get in data.txt is:

hello worldgoodbye

7stud – wrote:

You are supposed to be able to do this:

$OUTPUT_RECORD_SEPARATOR = “apple”

f = File.open(“data.txt”, “w”)
f.write “hello world”
f.write “goodbye”
f.close()

but the output I get in data.txt is:

hello worldgoodbye

Ok, I found one combination that allows me to define the output
separator:

  1. Use this assignment:

$\ = “apple”

  1. And the new output record separator only works with print(), not
    write():

#$OUTPUT_FIELD_SEPARATOR = “apple”
$\ = “apple”

x = “hello world”
y = “goodbye”

f = File.open(“data.txt”, “w”)
f.write x
f.write y
f.close #data.txt => hello worldgoodbye

STDOUT.write x
STDOUT.write y #terminal => hello worldgoodbye

f = File.open(“data.txt”, “w”)
f.print x
f.print y
f.close #data.txt => hello worldapplegoodbyeapple

print x
print y #terminal => hello worldapplegoodbyeapple

[email protected] schrieb:

Sure I can do that, but I thought it would be “cleaner” if I could to
something like:
file = new File…
file.newline_delimiter = ‘/r/n’
or
file.newline_delimiter = ‘dos’


Volker

ugly… newline_delimiter = ‘/r/n’ wouldn’t work as you expected =D
it should be \r\n right?

7stud – wrote:

Ok, I found one combination that allows me to define the output
separator:

Mac OSX 10.4.11