Can the nested loops be avoided? That's a good question.

The problem is that I have to map between the words I'm comparing and the original "un-modified" text.

Anyway, here's an example that runs.

http://hank.org/modules/PhraseTest.pm

(I think PerlMonk's wrapping code is too agressive in code blocks)

> dprofpp -u -p PhraseTest.pm Total Elapsed Time = 0.506468 Seconds User Time = 0.508234 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 61.0 0.310 0.430 30 0.0103 0.0143 PhraseHighlight::highligh +t_text 15.7 0.080 0.080 30 0.0027 0.0027 PhraseHighlight::build_hi +ghlighted _text 5.90 0.030 0.030 30 0.0010 0.0010 PhraseHighlight::substitu +e_highlig ht 3.94 0.020 0.020 15 0.0013 0.0013 Text::Wrap::wrap 1.97 0.010 0.010 30 0.0003 0.0003 PhraseHighlight::join_wor +ds 1.97 0.010 0.010 1 0.0100 0.0100 warnings::BEGIN 1.97 0.010 0.020 1 0.0100 0.0200 vars::BEGIN 1.97 0.010 0.010 2 0.0050 0.0050 PhraseHighlight::BEGIN 0.00 0.000 -0.000 2 0.0000 - vars::import 0.00 0.000 -0.000 3 0.0000 - Text::Tabs::BEGIN 0.00 0.000 -0.000 2 0.0000 - result::BEGIN 0.00 0.000 -0.000 4 0.0000 - constant::BEGIN 0.00 0.000 -0.000 1 0.0000 - warnings::register::impor +t 0.00 0.000 -0.000 2 0.0000 - warnings::register::mkMas +k 0.00 0.000 -0.000 1 0.0000 - strict::unimport
Thanks,

In reply to Re: Re: Context search term highlighting - Perl is too slow by moseley
in thread Context search term highlighting - Perl is too slow by moseley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.