[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01753] Re: Perl => Ruby

From: Dave Thomas <Dave@...>
Date: 2000-03-06 14:24:18 UTC
List: ruby-talk #1753
"Dat Nguyen" <thucdat@hotmail.com> 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

In This Thread

Prev Next