Installation of the module requires Perl5 version 5.003, and is very straightforward. Using the module to generate custom queries to a search engine is very simple.
First, the type of search engine must be defined. Check the documentation to see if the search engine you wish to query is supported, then create a new search:
$search = new WWW::Search(`SearchEngineName');
An example would be:
$search = new WWW::Search(`AltaVista');
Then specify the query string. This string is made up of some specific name value pairs, and is URI encoded.
$search->native_query(`search-engine-specific+query+string');
Here's a documented example which performs an AltaVista search, then prints the URIs resulting from the search. Note that you could easily add nice custom formatting of the results in the while loop.
my($search) = new WWW::Search::AltaVista; $search->native_query(WWW::Search::escape_query($query)); my($result); while ($result = $search->next_result()) { print $result->url, "\n"; };
Listing 10.1 is code from search.PL, a small example included with the WWW::Search distribution. This example illustrates the usage of the Search Library. Figure 10.2 depicts an example of output that could easily be generated by search.PL.