To say that this made things extremely faster would be a complete understatement. After being blown away at first, I ran a pseudo-benchmark, and noted that it cut my run time (on that section of code only) by a factor of at least 14! Thank you!
Just for the sake of my personal education, here is what I came up with based on your suggestion. Did I get it right? Or is there an even better way?
foreach $phrase (@key_phrases) {
my($worda,$wordb) = split(/ /, $phrase);
my $pattern = qr/(\W|\b)($worda)(\W+)($wordb)(\W|\b)/;
foreach (@material) {
last if (s,$pattern,$1<U>$2</U>$3<U>$4</U>$5,i);
}
}
Thanks again for your help and wisdom, great one.
-Gryphon.
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.