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

Re: [FWP] Matching regexp's at a stream of data?



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).

-Sven
-- 
I know you think you thought you knew what you thought I said,
but I'm not sure you understood what you thought I meant.

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe