* Phil Tomson (ptkwt / shell1.aracnet.com) [12 Jun 2003 11:58]:

[...]
> 1) Built-in types like Array seem to have more methods that work on them 
> than Perl's.  ie. you can do this out of the box in Ruby, but I don't 
> think you can in Perl:

> a = ['a','b','c','d','e']
> b = a - ['c']
> #b => ["a", "b", "d", "e"]

There's no operator overloading of this sort, no. Of course,
this particular task could be viewed as a convenient faíÂde
to the find and reject methods, which perl has as the grep
function.

    @b = grep { $_ != 4 } @a;
    b = a.reject { |e| e == 4 }

[...]
> 3) any type of object can be used as a key in a Ruby hash (Perl can
> only use strings as keys).

Although it should be noted that references will be happily
stringified if used as keys and that there is a core module
Tie::RefHash that lets you use 'real' references as keys.

[...]
> 5) yield and code blocks

These are trivial to implement, you just end up with a few
more keywords.

Basically, the main difference I usually see between Perl
and Ruby is that Ruby just gives you less 'noise'. Take away
various characters from a Perl program and you approach the
Ruby one. Start restructuring your code to be more Rubyish,
you lose even more.

You can do anything in Perl that you can in Ruby, it's just
that some things may require you to pull in a module or
write a few more characters.



cheers,
-- 
Iain.