NAME
CPAN::SQLite::Search - perform queries on the database
VERSION
version 0.220
SYNOPSIS
my $max_results = 200;
my $query = CPAN::SQLite::Search->new(db_dir => $db_dir,
db_name => $db_name,
max_results => $max_results);
$query->query(mode => 'module', name => 'Net::FTP');
my $results = $query->{results};
CONSTRUCTING THE QUERY
This module queries the database via various types of queries and returns the results for subsequent display. The CPAN::SQLite::Search object is created via the new method as
my $query = CPAN::SQLite::Search->new(db_dir => $db_dir,
db_name => $db_name,
max_results => $max_results);
which takes as arguments
db_dir => $db_dir
This is the directory where the database file is stored. This is optional if the
CPANoption is given.CPAN => $CPAN
This option specifies the
cpan_homedirectory of an already configured CPAN.pm, which is where the database file will be stored ifdb_diris not given.max_results => $max_results
This is the maximum value used to limit the number of results returned under a user query. If not specified, a value contained within
CPAN::SQLite::Searchwill be used.
A basic query then is constructed as
$query->query(mode => $mode, $type => $value);
with the results available as
my $results = $query->{results}
There are three basic modes:
module
This is for information on modules.
dist
This is for information on distributions.
author
This is for information on CPAN authors or cpanids.
module, dist, and author modes
For a mode of module, dist, and author, there are four basic options to be used for the $type => $value option:
query => $query_term
This will search through module names, distribution names, or CPAN author names and ids (for
module,dist, andauthormodes respectively). The results are case insensitive, and Perl regular expressions for the$query_termare recognized.name => $name
This will report exact matches (in a case sensitive manner) for the module name, distribution name, or CPAN author id, for
module,dist, andauthormodes respectively.id => $id
This will look up information on the primary key according to the mode specified. This is more for internal use, to help speed up queries; using this "publically" is probably not a good idea, as the ids may change over the course of time.
RESULTS
After making the query, the results can be accessed through
my $results = $query->{results};
No results either can mean no matches were found, or else an error in making the query resulted (in which case, a brief error message is contained in $query->{error}). Assuming there are results, what is returned depends on the mode and on the type of query. See CPAN::SQLite::Populate for a description of the fields in the various tables listed below - these fields are used as the keys of the hash references that arise.
author mode
nameoridqueryThis returns the
auth_id,cpanid,email, andfullnameof theauthstable. As well, an array reference$results->{dists}is returned representing all distributions associated with thatcpanid- each member of the array reference is a hash reference describing thedist_id,dist_name,dist_abs,dist_vers, anddist_filefields in thediststable. An additional entry,download, is supplied, which can be used as$CPAN/authors/id/$downloadto specify the url of the distribution.queryqueryIf this results in more than one match, an array reference is returned, each member of which is a hash reference containing the
auth_id,cpanid, andfullnamefields. If there is only one result found, anamequery based on the matchedcpanidis performed.
module mode
nameoridqueryThis returns the
mod_id,mod_name,mod_abs,mod_vers,dist_id,dist_name,dist_file,auth_id,cpanid,fullname, andemailof theauths,mods, anddiststables. As well, the following entries may be present.downloadThis can be used as
$CPAN/authors/id/$downloadto specify the url of the distribution.
queryqueryIf this results in more than one match, an array reference is returned, each member of which is a hash reference containing the
mod_id,mod_name,mod_abs,mod_abs,dist_vers,dist_abs,auth_id,cpanid,dist_id,dist_name, anddist_file. As well, adownloadfield which can be used as$CPAN/authors/id/$downloadto specify the url of the distribution is provided. If there is only one result found, anamequery based on the matchedmod_nameis performed.
dist mode
nameoridqueryThis returns the
dist_id,dist_name,dist_abs,dist_vers,dist_file,size,birth,auth_id,cpanid, andfullnameof theauths,mods, anddiststables. As well, the following entries may be present.downloadThis can be used as
$CPAN/authors/id/$downloadto specify the url of the distribution.modsThis is an array reference containing information on the modules present. Each entry is a hash reference containing the
mod_id,mod_name,mod_abs, andmod_versfields for the module.
queryqueryIf this results in more than one match, an array reference is returned, each member of which is a hash reference containing the
dist_id,dist_name,dist_abs,dist_file, andcpanidfields. As well, adownloadfield which can be used as$CPAN/authors/id/$downloadto specify the url of the distribution is provided. If there is only one result found, anamequery based on the matcheddist_nameis performed.
SEE ALSO
AUTHORS
Randy Kobes (passed away on September 18, 2010)
Serguei Trouchelle <stro@cpan.org>
COPYRIGHT
Copyright 2006,2008 by Randy Kobes <r.kobes@uwinnipeg.ca>.
Copyright 2011-2013 by Serguei Trouchelle <stro@cpan.org>.
Use and redistribution are under the same terms as Perl itself.