Hello monks,
I am posting this question in hopes of gaining some knowledge from someone that may have experimented with a solution for this at some point in their past. Also, I hope the responses will help other fellow monks when/if they seek this knowledge. I have over 100,000 files to look at, and each is a text file (.txt). What I want to do is reduce a lot of individual scripts that each perform their own REGEX against each file for a given phrase... into a single script that will do the same thing, but quickly, efficiently, and with something better than a loop through all the items or a huge REGEX with all the items (phrases) crammed one after the other. Ideally, I would like to use a hash of all the phrases being searched. I would like to know if there is a way to use a hash inside of a REGEX and make sure all the punctuation is understood (sorta like doing a quotemeta prior to running the regex). I am open to any method anyone has tested that they know will work. Over time, my list of files are going to grow and so are the phrases I will be searching for. I am guessing the phrases will increase into the thousands over time.
A sample phrase could be something like:
--->The cow jumped over the moon
-or-
--->110 Main Street, Huntington, AL, 55555
I sincerely appreciate any recommendations.
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.