Algorithm::AhoCorasick provides efficient search for multiple strings.
Aho-Corasick is a classic (1975) algorithm for locating elements of a finite set of strings within an input text. It constructs a finite state machine from a list of keywords, then uses the machine to locate all occurrences of the keywords.
Construction of the machine takes time proportional to the sum of the lengths of the keywords and the machine processes the input string in a single pass - that is, the algorithm may be considerably more efficient than searching for each keyword separately.
Product's homepage
Requirements:
· Perl
What's New in This Release: [ read full changelog ]
· Using weak references to avoid leaking memory (bug found and fixed by Daniel Kimsey, http://dekimsey.myopenid.com/ ).