Hello,


The Code:

====================================
def look_for_begin
   while line = gets
     if line =~ /^begin/
       puts line
       # return
     end
   end
end

ARGF.each { look_for_begin }
====================================

I have files with uuencoded and yencoded
data, and some text-only files, all in all 188 files,
and the size for all are about 16 MB.

The tool needs 3.6 seconds to look for the /^begin/
in all files.
When using exceptions, or break, or return (see the
comment above) to stop reading the file after a /^begin/
was found, I got no speedup!

I tries Perl, OCaml and C and all are a lot faster.
OK, if Ruby is slower, so it is.... and I have to live
with that.
But what I can NOT accept, is that the code needs the same
time with the statements and without the statements, that stop the
further reading of the files!

That seems very strange to mee!

Someone who can explain me this?

Thanks In Advance,
              Oliver