unknown wrote: > On Fri, Jul 9, 2010 at 1:22 PM, Francisco Martinez > <calabazag / hotmail.es> wrote: >> Hi...I'm trying to solve a very simple exercise but this is one of my >> first tasks and I can't manage to find a solution. >> I have a txt file and I have to write a method which; given the txt file >> as an entry argument returns an array of tokens. I have to call the >> method that prints the solutin in the screen. >> The solution should be this type: >> >> token 1= The >> token 2= man >> token 3= was > > How far have you made it? > * read from the file > * get the tokens from the file > * put the tokens into an array > * display the output I think I firstly have to do sometingh like this: def print_tokens(txtFile) f=File.open(txtFile) f.each do |line| if(line=~/\t(.+)/) puts("token= #{$1}") end f.close end end Here I don't have any array and something to indicate the number of each line...and it doesnt't work -- Posted via http://www.ruby-forum.com/.