in reply to Regexing an input stream...

You might find Applying regexes to streams: Perl enhancement idea an interesting read. It also includes a link to another example of how apply a regex to a stream using a sliding window.

                - tye