I'm writing a log file parser in Perl, using regexes that I've stored in a database. My workflow is basically like thi开发者_运维知识库s:
- Looping over the file and searching for patterns matching my regexes and then extract them
- Do something with these matches
- Store them accordingly in a database
Last time I did this I explicitly wrote each regex (not looping through each regex in the database), like this.
Now that I'm doing this again I was wondering if there were better solutions out there, better yet comments on what I've already done.
Thanks! =)
You might want to check out Regexp::Assemble
.
It will let you compose 1 regex that matches all of your regexes. It also claims it can track which of the original patterns the match corresponds too. I have not used this package before, though.
精彩评论