Perl Modules: Difference between revisions
Jump to navigation
Jump to search
(Copy from old, had no category, placed in Tutorials) |
(ADDED: upgrade modules) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category | [[Category:Tutorials]] | ||
==Getting To The CPAN Prompt== | ==Getting To The CPAN Prompt== | ||
To administer your Perl modules you must use the CPAN prompt. To get to the CPAN prompt, <b>as root</b> type: | To administer your Perl modules you must use the CPAN prompt. To get to the CPAN prompt, <b>as root</b> type: | ||
::<code> | ::<code>cpan</code> | ||
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 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. | ||
Line 11: | Line 11: | ||
::<code>o conf init</code> | ::<code>o conf init</code> | ||
==Listing The Installed Modules== | |||
From the BASH prompt: | |||
'''Easy way''' | |||
instmodsh | |||
l (L) | |||
'''Hard way''' | |||
use 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== | ==Installing New Modules== | ||
From the CPAN | From the CPAN prompt, type: | ||
install <Some::Module> | |||
Line 38: | Line 41: | ||
==Removing Modules== | ==Removing Modules== | ||
A clean way is by using this Perl program: | A clean way is by using this Perl program from the BASH prompt: | ||
#!/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; | |||
==Upgrade Modules== | |||
From the CPAN prompt, type: | |||
upgrade MODULE::NAME (to upgrade an individual module) | |||
'''or''' | |||
upgrade (to upgrade ALL modules) | |||
Latest revision as of 19:48, 29 August 2012
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:
cpan
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
From the BASH prompt:
Easy way
instmodsh l (L)
Hard way
use 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 prompt, type:
install <Some::Module>
Removing Modules
A clean way is by using this Perl program from the BASH prompt:
#!/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;
Upgrade Modules
From the CPAN prompt, type:
upgrade MODULE::NAME (to upgrade an individual module)
or
upgrade (to upgrade ALL modules)