NAME

Algorithm::UrataniTakeda - an implementation of the Uratani-Takeda string searching algorithm

VERSION

version v0.1.2

SYNOPSIS

my $m = Algorithm::UrataniTakeda->new( patterns => \@patterns );

my $match = $m->first($text);

my @all = $m->matches($text);

sub callback( $pos, $phrase ) {
    ...
    return 1;
}

while (<STDIN>) {
    $m->search( $_, \&callback );
}

STATUS

This is an experimental implementation. It may not be correct.

DESCRIPTION

This is an implementation of the Uratani-Takeda algorithm for searching for multiple strings.

It combines the Aho-Corasick algorithm with the Boyer-Moore algorithm, and is similar to the Commentz-Walter algorithm.

METHODS

sub callback( $pos, $phrase ) {
    ...
}

$m->search( $text, \&callback );

This searches the text and calls the callback function for every match.

If the callback returns a false value, it stops looking for additional matches.

matches

my @matches = $m->matches( $text );

This returns an array of all matches.

If there are no matches, then it will return an empty array.

first

my $match = $m->first( $text );

This returns the first match, or undef if there are none.

has_match

This returns true if there is a match.

This was added in v0.1.2.

SEE ALSO

This implementation was based on Uratani N. and Takeda M., "A Fast String-Searching Algorithm for Multiple Patterns", Information, Processing & Management 29 (6), pp. 775-791, 1993. doi:10.1016/0306-4573(93)90106-N.

SOURCE

The development version is on github at https://github.com/robrwo/perl-Algorithm-UrataniTakeda and may be cloned from https://github.com/robrwo/perl-Algorithm-UrataniTakeda.git

SUPPORT

Only the latest release of this module will be supported.

This module requires Perl v5.26 or later.

Reporting Bugs and Submitting Feature Requests

Please report any bugs or feature requests on the bugtracker website https://github.com/robrwo/perl-Algorithm-UrataniTakeda/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see SECURITY.md for instructions how to report security vulnerabilities.

AUTHOR

Robert Rothenberg <perl@rhizomnic.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Robert Rothenberg.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)