Ruby pipe with arguments error


#1

i am newbie of ruby , but i met a strange problem
when use

#echo hello |ruby -ve ‘puts ARGF.readlines’
ruby 1.8.3 (2005-09-21) [i686-linux]
hello

it’s ok

but when i append a argument with pipe

echo hello |ruby -ve ‘puts ARGF.readlines’ somearg

ruby 1.8.3 (2005-09-21) [i686-linux]
-e:1:in `readlines’: No such file or directory - somearg
(Errno::ENOENT)
from -e:1

why ruby say ‘no such file or diectory’? can anyboby explain it?

thanks


#2

Hi,

At Thu, 8 Dec 2005 13:17:35 +0900,
cap wrote in [ruby-talk:169506]:

why ruby say ‘no such file or diectory’? can anyboby explain it?

ARGF doesn’t equal STDIN.

Quotation from the document:

  • The global constant ARGF (also accessible as $<) provides an
  • IO-like stream which allows access to all files mentioned on the
  • command line (or STDIN if no files are mentioned).