From: "ara.t.howard" Date: 2007-10-31T02:00:01+09:00 Subject: Re: loop until a key (i.e. enter or ESC) is pressed On Oct 30, 2007, at 10:38 AM, Wurzel Cidermaker wrote: > > def loopy > > loop do > > puts Time.now > sleep 1 > > end > > end > > reaper = > Thread.new do > loop do > Kernel.exit if gets == 'exit' > end > end > > loopy sorry, my fault, that 'gets' will have a newline on it, this works: cfp:~ > ruby a.rb Tue Oct 30 11:01:32 -0600 2007 Tue Oct 30 11:01:33 -0600 2007 Tue Oct 30 11:01:34 -0600 2007 Tue Oct 30 11:01:35 -0600 2007 Tue Oct 30 11:01:36 -0600 2007 exit cfp:~ > cat a.rb def loopy loop do puts Time.now sleep 1 end end reaper = Thread.new do loop do Kernel.exit if gets =~ /exit/ end end loopy regards. a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama