From: Matthew Smillie Date: 2006-06-12T03:45:55+09:00 Subject: Re: gets problem - strange On Jun 11, 2006, at 19:21, Jim Freeze wrote: > This is a problem that was pointed out by Esteban Velazquez. > > % cat gets2.rb > #!/usr/bin/ruby > > print "getting "; puts gets > > Sending the app arguments returns an error: > > % ruby gets2.rb fred > gets2.rb:3:in `gets': No such file or directory - fred > (Errno::ENOENT) > from gets2.rb:3 > > But, with no arguments, it runs ok. Check the documentation for the method: http://ruby-doc.org/core/classes/Kernel.html#M002976 "Returns (and assigns to $_) the next line from the list of files in ARGV (or $*), or from standard input if no files are present on the command line." You can explicitly use $stdin.gets or STDIN.gets to get the behaviour you want. matthew smillie.