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

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



At 07:20 AM 08/02/2000 +0200, Sven Neuhaus wrote:
>Hi perl people,
>
>I'm working on a rewriting web-proxy (free, of course :-). 
>The idea is that there is a list of regexps to be matched
>against everything that goes through the proxy, with the
>possibility of changing the stream if there is a match.
>Simple example:
>     Look for /<font size=[12]>/ and 
>replace with '<font size=3>'.
>
>The problem I'm facing is finding a good way to match
>(possibly many) regexps against a stream. The stream may be very 
>large so I want to start doing matched before the end of the stream
>has been reached.
>To make this easier, every regexp has a parameter that specifies 
>the maximum number of bytes to be matched.

My reference example for dealing with streams of data while
searching for matches (though not necessarily regexp driven)
was the Net::Telnet module.  IIRC Jay Rogers has code to fill
and then then parcel out data (rewritten or not) from buffers
as he recognizes (or doesn't) the data received.  As long as
you have the maximum possible match lengths you should be able
to make a table-driven adaption of his buffering.


>Any clever ideas how to code this in perl in a elegant and
>fast manner?

I don't know that he would claim his buffering as fast/elegant,
but sufficient and necessary.

Tom Shinnick
tshinnic@io.com



>Ideas welcome.
>
>-Sven
>PS: If you don't understand what I'm talking about, have a look
>     at the Windows program Proxomitron, proxomitron.tripod.com
>-- 
>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


-- 
When time permits, your personal life will be exciting.
   -- Chinese Restaurant Fortune Cookie   (They know me there ...)

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