开发者

Perl best practices: file parser using regexes and database storage

开发者 https://www.devze.com 2023-01-13 17:54 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消