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 -- share your knowledge. it's a way to achieve immortality. - h.h. the 14th dali lama