From: Tim Hammerquist Date: 2002-05-09T06:59:10+09:00 Subject: Re: Want application to read file or from pipe Jim Freeze graced us by uttering: > Does anyone have a sample application that can read > a file given on the commandline or read from a pipe. > I am interested in how one would recognize the difference > from the command-line and how the internal file handling > would change. This perl-like example should work: $ cat filter.rb #!/usr/local/bin/ruby -w while gets # each line given in $_ for each iteration puts "you gave me: #$_" end $ ls | filter.rb you gave me: Mail you gave me: News you gave me: bin you gave me: build you gave me: lib you gave me: public_html $ filter.rb .gvimrc you gave me: " GVim 6.1 you gave me: set background=dark you gave me: set columns=80 lines=64 $ filter.rb < /dev/bollocks you gave me: orchestrate bricks-and-clicks metrics $ Is that what you had in mind? Tim Hammerquist -- guru, n: a computer owner who can read the manual.