in reply to foreach (@array) s/x/y/ efficiency
However you quite likely need to ignore case, and judging by your code you have other conditions which this code won't do. Of course you might be able to fix that with use of lc and maybe some preprocessing, but if your doing that you might destroy any speed gains.$text = join("\n",@material); for my $phrase (@key_phrases) { my $pos = index $text, $phrase; if ($pos == -1) { warn "Phrase: $phrase not found\n"; } substr($text, $pos, 0) = '<B>'; substr($text, ($pos+length($phrase)), 0) = '</B>'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: foreach (@array) s/x/y/ efficiency
by gryphon (Abbot) on Jan 11, 2001 at 02:53 UTC |