in reply to Re: I agree, but...
in thread Runtime Regexp Generation

It appears to me that there is no need to make the fields fixed-length since the fields appear to never contain whitespace and always to be separated by whitespace so it is not that hard to build a regex that matches exactly as desired.

                - tye
  • Comment on Re^4: Runtime Regexp Generation (I agree, but...)

Replies are listed 'Best First'.
Re: Re^4: Runtime Regexp Generation (I agree, but...)
by dmitri (Priest) on Apr 14, 2003 at 22:38 UTC
    I wrote a generic log-reader combined with a custom query language (looked like SQL, and I based it on Parse::RecDescent) several years ago. It supported reading fields from comma(or anything else)-separated records, regex-separated records, or a custom regex. Once an object was defined, each read would return an array wanted fields from the next line, that were fed to precompiled query for evaluation.

    I don't have the code handy, but this solution can be abstracted very nicely. One gotcha is that it was quite slow, esp. if regular expressions were used to extract values from each line (I'm talking hundreds of megabytes of logs).