|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello all. I'm trying to use the gets function, only I want to read
in a file and make separators any sort of punctuation(",", ":", "\n", etc.). My problem is trying to understand how the sep_string=$/ option is supposed to work: ios.gets(sep_string=$/) How can I specify what sep_string is so that when I do something for a while loop on gets, I can get each word instead of a line of text, or lines of text with various punctuation I don't want? A second note, I'm not sure what $/ is supposed to mean. Is that the separator for newline(which i thought was \n)? Thanks in advance. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 9/16/07, ZyLo <Klauer@gmail.com> wrote:
> Hello all. I'm trying to use the gets function, only I want to read > in a file and make separators any sort of punctuation(",", ":", "\n", > etc.). > > My problem is trying to understand how the sep_string=$/ option is > supposed to work: > > ios.gets(sep_string=$/) > > How can I specify what sep_string is so that when I do something for a > while loop on gets, I can get each word instead of a line of text, or > lines of text with various punctuation I don't want? > > A second note, I'm not sure what $/ is supposed to mean. Is that the > separator for newline(which i thought was \n)? > $/ is the 'output separator' global. It defaults to \n. What that syntax is saying is that you can pass a separator string to IO#gets, and it will use it. If you don't pass it one, it will use whatever $/ is set to. |
|
![]() |
| Outils de la discussion | |
|
|