Винная безопасность - Улучшение второй учетной записи пользователя?

Это версия Ruby

str_list = ['text', 'thing', 'try', 'Better']

File.open(ARGV[0]) do |f|
  lines = f.readlines
  lines.each_with_index do |l, idx|
    if l.match(str_list[idx])
      l = l.split(' ')
      if l.length == 1
        puts l[0]
      else
        puts l[0] + "\t" + str_list[idx]
      end
    end
  end
end

В образце текстового файла hello.txt содержится

This is a single text line
Another thing
It is better you try again
Better

Запуск с ruby source.rb hello.txt приводит к

This    text
Another thing
It      try
Better
1
задан 17 November 2011 в 13:47

0 ответов

Другие вопросы по тегам:

Похожие вопросы: