B
BearItAll
Hello, I'm new here, also fairly new to ruby, but I already have some
very usfull scripts written with it.
But a problem I have over and over is that the 'chop' doesn't always
work (for me) when dealing with files.
An example, the file '/tmp/dirtree' is the result of a class that
traverses the directory tree, the lines are written using,
f.print "#{filename}\n"
(but I've also tried others writing methods)
Then next would be the class to read from that file.
DIRTREE='/tmp/dirtree'
IO.foreach(DIRTREE) { |@x|
@x.chop
print "Thisdir = #{@x}/*"
}
The output from print gives,
Thisdir = /home/whatever
/*
So chop hasn't removed the newline.
Do you use a definitive combination of file write and read that will
always work, or is there another trick I don't know about yet.
PS: I' on UNIX/Linux.
Thankyou
very usfull scripts written with it.
But a problem I have over and over is that the 'chop' doesn't always
work (for me) when dealing with files.
An example, the file '/tmp/dirtree' is the result of a class that
traverses the directory tree, the lines are written using,
f.print "#{filename}\n"
(but I've also tried others writing methods)
Then next would be the class to read from that file.
DIRTREE='/tmp/dirtree'
IO.foreach(DIRTREE) { |@x|
@x.chop
print "Thisdir = #{@x}/*"
}
The output from print gives,
Thisdir = /home/whatever
/*
So chop hasn't removed the newline.
Do you use a definitive combination of file write and read that will
always work, or is there another trick I don't know about yet.
PS: I' on UNIX/Linux.
Thankyou