From: Dat Nguyen Date: 2000-03-06T10:49:28-05:00 Subject: [ruby-talk:01754] Re: Perl => Ruby OZAWA -Crouton- Sakuro already instructed me how to do it as follows: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Interactive one already exists in the official dists. Just get any binary/(or get the source and make), then try the below: $ ruby -r 'irb/main' -e IRB.start [ENTER] irb(main):001:0> def fib(x) irb(main):002:1> x < 2 ? 1 : fib(x-1) + fib(x-2) irb(main):003:1> end nil irb(main):004:0> fib(3) 3 irb(main):005:0> fib(5) 8 irb(main):006:0> exit $ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> It works great on my Linux box, no need to download anything extra. However, as seen from the 'irb/main', it's not applicable for my WIN/NT. That's why I am trying to work around, since I don't have any tool to recompile Ruby on my WIN/NT. Regards, Dat >From: Dave Thomas >Reply-To: ruby-talk@netlab.co.jp >To: ruby-talk@netlab.co.jp (ruby-talk ML) >Subject: [ruby-talk:01753] Re: Perl => Ruby >Date: 06 Mar 2000 08:24:18 -0600 > >"Dat Nguyen" writes: > > > How to write the following Perl code in Ruby: > > > > while (<>) { eval; print $@; } > >It isn't as concise, as Ruby returns eval errors as exceptions: > > while gets > begin > eval $_ > rescue > puts $! > end > end > >You might also want to have a look at sample/eval.rb in the >distribution. If you want an interactive way to execute Ruby, you >might also want to check out 'irb'. > >Regards > >Dave ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com