From: Brian Candler Date: 2010-01-13T05:23:50+09:00 Subject: Re: SPOJ ? Test for end of file input Aldric Giacomoni wrote: > It's pretty trivial, but it doesn't have a well-delimited "end" to it. > In the forums, they indicate one should test for end of file. I have no > idea how to do that in Ruby. gets will return nil on end of file. while line = $stdin.gets line.chomp! puts "I got #{line} !!" end > I can only suppose they're using the "-i" argument ... If so, how do I > test for when that file has run out of stuff? huh? -i is "in-place edit mode". It makes ruby read in one or more files (whose names are listed on the command line), and write them back out again with modifications under the original names, optionally renaming the original file to a different name. You'd use it if you were using ruby to do search-and-replace type operations. -- Posted via http://www.ruby-forum.com/.