Tutorial by Examples

do './config.pl'; This will read in the contents of the config.pl file and execute it. (See also: perldoc -f do.) N.B.: Avoid do unless golfing or something as there is no error checking. For including library modules, use require or use.
require Exporter; This will ensure that the Exporter module is loaded at runtime if it hasn't already been imported. (See also: perldoc -f require.) N.B.: Most users should use modules rather than require them. Unlike use, require does not call the module's import method and is executed at runti...
use Cwd; This will import the Cwd module at compile time and import its default symbols, i.e. make some of the module's variables and functions available to the code using it. (See also: perldoc -f use.) Generally this is will do the right thing. Sometimes, however, you will want to control whic...
use lib 'includes'; use MySuperCoolModule; use lib 'includes'; adds the relative directory includes/ as another module search path in @INC. So assume that you have a module file MySyperCoolModule.pm inside includes/, which contains: package MySuperCoolModule; If you want, you can group as ma...
CPAN.pm is a Perl module which allows to query and install modules from CPAN sites. It supports interactive mode invoked with cpan or perl -MCPAN -e shell Querying modules By name: cpan> m MooseX::YAML By a regex against module name: cpan> m /^XML::/ Note: to enable a pager o...
From command line: cpan -l From a Perl script: use ExtUtils::Installed; my $inst = ExtUtils::Installed->new(); my @modules = $inst->modules();

Page 1 of 1