It depends on the frequency of the matches. I'm convinced that one call to
index() on a string of 10k, with a negative result, or just a few matches, is a lot faster than 10000 calls to
getc() and the same number of
eq tests. It's a matter of doing the same task in C, or in Perl. C usually wins hands down.