I just learned about Ruby two days ago, and spent all day Friday
learning it.  It's TOTALLY KILLER...  I thought I liked Perl...  WOW.
This has me swimming.  Not to mention that I've never really soaked
myself into anything OO -- no time.  Well, I made the time, and this is
awesome.  I'm already extending base classes for some really elegant and
quick solutions...  OO is cool too.

Anyway, enough of the accolades, well deserved though they are.  Way to
go Matz...

I can't seem to find the Ruby syntax that is equivalent to the following
in Perl:

while (<>) { DoAnyThing( $_ ) }

Basically, read from the already-opened stdin, and do stuff with it,
using $_.  I use this all the time in Perl to test things from the Unix
command line, esp. formulating my RegEx, so I don't have to write little
test programs in vi, chmod 755, etc...  I can just type in the line, and
test at the command line:

$ perl -e 'while (<>) { if (/^\d/) { print "Starts with digit\n" } else
{ print "Nope\n" } }'
123
Starts with digit
Hey!
Nope
^D

How can I do the same in Ruby?  There's got to be a way!  I thought
this:

while gets do |line|
   DoSomethingWith( line )
end

But that doesn't work...  If anyone can shed any light on this, it would
help me finish learning this wonderful language, as I can type in quick
tests as I read at www.ruby-lang.org...  A copied reply to my email
would be appreciated...

Chris Olive
-----
New Ruby Advocate
colive / NOSPAM.technologEase.com