Rather than sending its results to a user, the indexer dumps all information it has about word frequency and usage and places it in a file on disk. This means the search program the user invokes via CGI does not actually have to search. Instead, the search program merely opens the index file, finds those files where the user's search term appears the greatest number of times, and displays that list in the user's browser. Indexing a page is not difficult in Perl, because of its rich library of regular expressions. In this case, the caller is Perl's join operator, which pushes the elements together, separated by spaces.
Indexers have to consider whether to keep case relevant.
My personal preference is to ignore case, since users do not necessarily remember, and it also removes an obstacle to finding desired text. The keys will be words we wish to ignore when indexing. The value will be a hash reference, where the key is the name of the current file, and the value is the number of times this word appears in the file. This subroutine takes a subroutine reference and a list of directories as arguments. It is the subroutine's responsibility to open the file, retrieve its contents, and index it as necessary.