CPANPLUS::Backend
my $cb = CPANPLUS::Backend->new( ); my $conf = $cb->configure_object; my $author = $cb->author_tree('KANE'); my $mod = $cb->module_tree('Some::Module'); my $mod = $cb->parse_module( module => 'Some::Module' ); my @objs = $cb->search( type => TYPE, allow => [...] ); $cb->flush('all'); $cb->reload_indices; $cb->local_mirror;
This module provides the programmer's interface to the CPANPLUS libraries.
CPANPLUS
When CPANPLUS::Backend is loaded, which is necessary for just about every <CPANPLUS> operation, the environment variable PERL5_CPANPLUS_IS_RUNNING is set to the current process id.
PERL5_CPANPLUS_IS_RUNNING
This information might be useful somehow to spawned processes.
This method returns a new CPANPLUS::Backend object. This also initialises the config corresponding to this object. You have three choices in this:
CPANPLUS::Configure
This will be used verbatim.
These will override your existing config, but use your default config for options you didn't specify.
Your default config will be loaded and used.
New will return a CPANPLUS::Backend object on success and die on failure.
Returns a reference to the CPANPLUS module tree.
If you give it any arguments, they will be treated as module names and module_tree will try to look up these module names and return the corresponding module objects instead.
module_tree
See CPANPLUS::Module for the operations you can perform on a module object.
Returns a reference to the CPANPLUS author tree.
If you give it any arguments, they will be treated as author names and author_tree will try to look up these author names and return the corresponding author objects instead.
author_tree
See CPANPLUS::Module::Author for the operations you can perform on an author object.
Returns a copy of the CPANPLUS::Configure object.
See CPANPLUS::Configure for operations you can perform on a configure object.
search enables you to search for either module or author objects, based on their data. The type you can specify is any of the accessors specified in CPANPLUS::Module::Author or CPANPLUS::Module. search will determine by the type you specified whether to search by author object or module object.
search
type
CPANPLUS::Module::Author
CPANPLUS::Module
You have to specify an array reference of regular expressions or strings to match against. The rules used for this array ref are the same as in Params::Check, so read that manpage for details.
Params::Check
The search is an or search, meaning that if any of the criteria match, the search is considered to be successful.
or
any
You can specify the result of a previous search as data to limit the new search to these module or author objects, rather than the entire module or author tree. This is how you do and searches.
data
and
Returns a list of module or author objects on success and false on failure.
See CPANPLUS::Module for the operations you can perform on a module object. See CPANPLUS::Module::Author for the operations you can perform on an author object.
Fetches a list of modules. @mods can be a list of distribution names, module names or module objects--basically anything that parse_module can understand.
@mods
See the equivalent method in CPANPLUS::Module for details on other options you can pass.
Since this is a multi-module method call, the return value is implemented as a CPANPLUS::Backend::RV object. Please consult that module's documentation on how to interpret the return value.
CPANPLUS::Backend::RV
Extracts a list of modules. @mods can be a list of distribution names, module names or module objects--basically anything that parse_module can understand.
Installs a list of modules. @mods can be a list of distribution names, module names or module objects--basically anything that parse_module can understand.
Fetches the readme for a list of modules. @mods can be a list of distribution names, module names or module objects--basically anything that parse_module can understand.
Returns a list of files used by these modules if they are installed. @mods can be a list of distribution names, module names or module objects--basically anything that parse_module can understand.
Returns a list of module objects representing all releases for this module on success. @mods can be a list of distribution names, module names or module objects, basically anything that parse_module can understand.
parse_module tries to find a CPANPLUS::Module object that matches your query. Here's a list of examples you could give to parse_module;
parse_module
These items would all come up with a CPANPLUS::Module object for Text::Bastardize. The ones marked explicitly as being version 1.06 would give back a CPANPLUS::Module object of that version. Even if the version on CPAN is currently higher.
Text::Bastardize
If parse_module is unable to actually find the module you are looking for in its module tree, but you supplied it with an author, module and version part in a distribution name, it will create a fake CPANPLUS::Module object for you, that you can use just like the real thing.
If even this fancy guessing doesn't enable parse_module to create a fake module object for you to use, it will warn about an error and return false.
This method reloads the source files.
If update_source is set to true, this will fetch new source files from your CPAN mirror. Otherwise, reload_indices will do its usual cache checking and only update them if they are out of date.
update_source
reload_indices
By default, update_source will be false.
The verbose setting defaults to what you have specified in your config file.
Returns true on success and false on failure.
This method allows flushing of caches. There are several things which can be flushed:
methods
The return status of methods which have been attempted, such as different ways of fetching files. It is recommended that automatic flushing be used instead.
hosts
The return status of URIs which have been attempted, such as different hosts of fetching files. It is recommended that automatic flushing be used instead.
modules
Information about modules such as prerequisites and whether installation succeeded, failed, or was not attempted.
lib
This resets PERL5LIB, which is changed to ensure that while installing modules they are in our @INC.
load
This resets the cache of modules we've attempted to load, but failed. This enables you to load them again after a failed load, if they somehow have become available.
all
Flush all of the aforementioned caches.
Returns a list of module objects of all your installed modules. If an error occurs, it will return false.
Creates a local mirror of CPAN, of only the most recent sources in a location you specify. If you set this location equal to a custom host in your CPANPLUS::Config you can use your local mirror to install from.
CPANPLUS::Config
It takes the following arguments:
The location where to create the local mirror.
Enable/disable fetching of index files. This is ok if you don't plan to use the local mirror as your primary sites, or if you'd like up-to-date index files be fetched from elsewhere.
Defaults to true.
Forces refetching of packages, even if they are there already.
Defaults to whatever setting you have in your CPANPLUS::Config.
Prints more messages about what its doing.
Writes out a snapshot of your current installation in CPAN bundle style. This can then be used to install the same modules for a different or on a different machine.
CPAN
It will, by default, write to an 'autobundle' directory under your cpanplus homedirectory, but you can override that by supplying a path argument.
path
It will return the location of the output file on success and false on failure.
This module by Jos Boumans <kane@cpan.org>.
The CPAN++ interface (of which this module is a part of) is copyright (c) 2001, 2002, 2003, 2004, Jos Boumans <kane@cpan.org>. All rights reserved.
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
CPANPLUS::Configure, CPANPLUS::Module, CPANPLUS::Module::Author
To install CPANPLUS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CPANPLUS
CPAN shell
perl -MCPAN -e shell install CPANPLUS
For more information on module installation, please visit the detailed CPAN module installation guide.