Here's another example with significantly bigger performance difference:

Ruby:

s = "This is a test string"

re = Regexp.new( / test / )

for a in 0..1E7
        re.match( s )
end

Perl:

my $s = "This is a test string";

for my $a ( 0..1E7 ) {
       $s =~ / test /;
}

Perl takes about 1.5 seconds to execute this, while Ruby takes a 
whopping 16!!! :((( I have a very strong feeling that I didn't compile 
Ruby properly - there can't be such a huge difference in regexp matching 
:(

-- 
Posted via http://www.ruby-forum.com/.