[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 'out of memory' errors



tom arnall wrote:

>> What about streams then?
> 
> please tell me how that would work? i'm not familiar with the mechanism.

You could open a file as a stream (or a buffer, it is the same thing),
read it in chunks of reasonable length (maximum length you expect the
longest regex match would span), and advance by one char, for example.
Something like this...

|----------- $number of chars -----------|-----------
-|----------- $number of chars -----------|----------
--|----------- $number of chars -----------|---------
---|----------- $number of chars -----------|--------

There are many ways to implement this and similar algorithms. Google for
perl, buffers, streams, and regexes to locate examples.



Reply to: