
OnSearch::StringSearch - String search library for OnSearch.

use OnSearch::StringSearch;
@offsets = search_string ($pattern, $text);
@offsets = search_file ($pattern, $filename);
$offset = strindex ($pattern, $text);

Search_string () searches for the exact matches a string within another string, without performing regular expression pattern matching. Strindex searches for the first exact match. Search_file () searches a file for occurrences of a string.
In a list context, search_string () and search_file () return a list of file offsets where the pattern occurs in the search text, or a reference to the list in scalar context. Strindex () returns the offset of the first occurence. The subroutines return undef if the search pattern is not found.

Returns the first occurence of pattern in text, or undef otherwise.
Returns a list of offsets in text where pattern is found, or undef otherwise.
Returns a list of offsets in the input file where pattern is found, or undef otherwise.

$Id: StringSearch.pm,v 1.4 2005/07/25 00:33:01 kiesling Exp $
Copyright © 2005 Robert Kiesling, rkies@cpan.org.
Licensed under the same terms as Perl. Refer to the file, "Artistic," for details.
The search strategies are from the Boyer-Moore search algorithm as described in Michael Abrash's Graphics Programming Black Book.