On Thu, Aug 03, 2000 at 04:43:10AM +0200, Sven Neuhaus wrote: > On Wed, Aug 02, 2000 at 08:54:19PM -0400, abigail@foad.org wrote: > > local $_; > > sysread $fh => $_, $maxchars or return; > > do {s/^pattern1/replacement1/ and next; # Note the anchor. > > s/^pattern2/replacement2/ and next; > > ... > > } while defined substr $_ => 0, 1, "" and > > (sysread $fh => $_, length, 1 or length); > > That's probably too slow, isn't it? > > I was thinking when I have a max match size of, say, 400 bytes, the > algorithm looks at 600 bytes then slides the window 200 bytes further. > There must be some overlap or you will miss some matches. Testing > every byte is too slow, though (haven't benchmarked it, but I'd be > fairly surprised if it weren't). If you don't advance by one byte at a time, you can't anchor the regexp to the beginning of the string. If you don't anchor the regex to the beginning of the string, how do you prevent the regex from matching, for example, the last 200 characters in the stream? I'm sure it can be done, but you need to be aware of it. Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe