10.2 Transforming XML 235
rather more liketissuesthan organs or organisms, because all of the entities
that make up the collection are the same kind of entity. With modules and
objects, the grouping includes entities that are dissimilar. Thus one can group
together scalars, arrays, hashes, procedures, and so on, all in a single unit.
Modules are mainly used for publishing programs. One person or group
of persons constructs a module for a specialized purpose. The module is then
published, usually at the Comprehensive Perl Archive Network (CPAN) lo-
cated atcpan.org. The modules can then be downloaded and installed by
other people. If you have installed your own personal Perl library, then you
can look for and install modules by running thecpancommand. If you have
Perl, but do not havecpan, then try the following command:
perl -MCPAN -e shell
If you don’t have Perl, then you will need to install it.
Thecpancommand (or its equivalent) presumes that you know which
modules you want to install. If you do not know which ones you would like,
then use one of the CPAN search engines, such assearch.cpan.org. There
are over 100 packages that mention bioinformatics, plus there are many oth-
ers related to biology and medicine.
Once a module has been installed, the most common way for it to be used
is to construct amodule object. Programs that use modules typically look
something like this:
use moduleName;
$p = new moduleName;
...
Theusestatement tells Perl that the program will be using a module. One
can use any number of modules. Thenewstatement constructs anobject.An
object is a reference to a collection of scalars, arrays, hashes, procedures, and
other objects, all of which have been grouped together in a single unit. The
parts of an object are obtained by using a special operator, written->. For
example, if one of the parts of the module object$pis a procedure named
computeAverage, then the procedure is invoked by using the statement
$p->computeAverage;
Procedures that are in the context of an object are calledmethods.