ara.t.howard / noaa.gov wrote: > gets is a method of IO and it does read from piped input. > however, there is a magic variable called ARGF which is the list of > all files on the command line, or stdin if none are given. so 'cat', > in ruby could be written as > > ARGF.each{|line| print line} > So far, so good. Makes perfect sense. What is more perplexing is that the formula for console I/O would look like this: puts prompt_string STDIN.gets --succeeds? Why would standard input work there, but fail in this case: puts prompt_string gets --fails? If no file is specified on the command line, why doesn't that invocation gets do the same thing as STDIN.gets? ara.t.howard / noaa.gov wrote: > On Tue, 28 Mar 2006, Eric Armstrong wrote: > >> ara.t.howard / noaa.gov wrote: >>> On Tue, 28 Mar 2006, Ernest Obusek wrote: >>> >>>> #!/usr/bin/ruby >>>> >>>> puts "Timer set to #{ARGV[0]} seconds. Press <ENTER> to start the >>>> countdown." >>>> gets >>>> >>>> It seems to think the argument of 60 should be a file or >>>> directory... ???? >>> >>> you have not given a receiver to gets and the default one is ARGF >>> (see pickaxe for desc). try >>> >>> STDIN.gets >>> >> That almost makes sense, except for the name of the receiver. >> gets is supposed to read from a file, if specified. Otherwise >> it reads from piped input (according to the ancient books I've >> consulted). >> >> I can understand that you would need to specify a different >> receiver to specify "current console device". But surely >> the input pipe is standard input, yes? So STDIN is the current >> console device, and that's not the same as standard in??? >> >> Signed, Confused in Peoria. >> :_) >> > > yes and no. first off gets is a method of IO and it does read from piped > input. however, there is a magic variable called ARGF which is the list of > all files on the command line, or stdin if none are given. so 'cat', in > ruby > could be written as > > ARGF.each{|line| print line} > > and this would work with > > cat one | ruby a.rb > ruby a.rb < two > ruby a.rb one two three > > make sense? see ARGF in pickaxe for more. > > regards. > > -a