By looping over your masks inside a loop over the lines over your log file, you are forcing to recompile a new regex for each line, for each mask. So, if you have 5 masks, and 100,000 lines in your log file, you are forcing Perl to compile 500,000 regular expressions.
If you have one mask, Perl knows the regex hasn't changed, so it won't recompile - hence you will compile only one regex, despite your 100,000 lines of code.
You can do two things - either switch the order of the loops , that is, for each mask, create a regex, then loop over the log file (first seeking back to the start of the file!), or create an array of compiled regular expressions, and loop over them.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.