From: Daniel Carrera Date: 2003-09-03T12:34:04+09:00 Subject: Re: How to bail from an iteration but not the program?... You can use 'break': dcarrera ~ $ cat control.txt line 1 line 2 line 3 line 4 line 5 dcarrera ~ $ cat test.rb IO.foreach("control.txt") do |x| puts "Stuff A goes here: #{x}" break if x =~ /3/ end puts "Stuff B goes here" dcarrera ~ $ ruby test.rb Stuff A goes here: line 1 Stuff A goes here: line 2 Stuff A goes here: line 3 Stuff B goes here dcarrera ~ $ Cheers, Daniel. On Wed, Sep 03, 2003 at 12:23:20PM +0900, Kurt Euler wrote: > All- > > How can I terminate the running of a program from within an iteration, but not leave the program? > > EG, In this code: > > IO.foreach("control.txt") { |x| > field = x.chop.split("\t", -1) > > control.txt file occurs and continue with stuff B> > } > > ... > ... > ... > end > > > Thanks for your comments (and to those who assisted recently with the abort command). > > -Kurt -- Daniel Carrera, Math PhD student at UMD. PGP KeyID: 9AF77A88 .-"~~~"-. / O O \ ATTENTION ALL PASCAL USERS: : s : \ \___/ / To commemorate the anniversary of Blaise Pascal's `-.___.-' birth (today) all your programs will run at half speed.