Perl Modules

From SlackWiki
Revision as of 21:17, 6 June 2009 by Erik (talk | contribs) (Copy from old, had no category, placed in Tutorials)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

[[Category::Tutorials]]

Getting To The CPAN Prompt

To administer your Perl modules you must use the CPAN prompt. To get to the CPAN prompt, as root type:

perl -MCPAN -e shell

If this is the first time that you have entered the CPAN shell, you will be asked some set-up questions that will allow the shell to access CPAN's servers to get modules. Just read the questions and answer them.

If you ever need to re-run the set-up again, enter the CPAN shell and then type:

o conf init


Listing The Installed Modules

As of Slackware 10.2 and Perl 5.8.7- you can look the perllocal.pod file and see the modules.

cat /usr/lib/perl5/5.8.7/i486-linux/perllocal.pod


A much cleaner way is by using this Perl program:

#!/usr/bin/perl
use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules())
{
my $version = $instmod->version($module) || "???";
print "$module -- $version\n";
}

Installing New Modules

From the CPAN shell prompt, type:

install <Some::Module>


Removing Modules

A clean way is by using this Perl program:

#!/usr/bin/perl -w
use ExtUtils::Packlist;
use ExtUtils::Installed;
$ARGV[0] or die "Usage: $0 Module::Name\n";
my $mod = $ARGV[0];
my $inst = ExtUtils::Installed->new();
foreach my $item (sort($inst->files($mod)))
{
print "removing $item\n";
unlink $item;
}
my $packfile = $inst->packlist($mod)->packlist_file();
print "removing $packfile\n";
unlink $packfile;