in reply to Re: character-by-character in a huge file
in thread character-by-character in a huge file

One character each time, why not? Perl already buffers the file so getc should be faster than a lot of magic with substr (or unpack).

  • Comment on Re: Re: character-by-character in a huge file

Replies are listed 'Best First'.
Re: Re: Re: character-by-character in a huge file
by bart (Canon) on Apr 10, 2004 at 12:26 UTC
    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.