Perl Modules quick Tips

How to check if perl module is installed?

A. Checking if Perl Module is Installed

This is important on checking if a given perl module is already installed or not.

Code:

#perl -MModule::Name -e 1

if present, no errors appeared:
[root@darwin ~]# perl -MNet::SNMP -e 1

without:

[root@darwin ~]# perl -MNet::Telnet -e 1

Can’t locate Net/Telnet.pm in @INC (@INC contains: /usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl /usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/local/lib/perl5/site_perl /usr/lib/perl5/site_perl .).
BEGIN failed–compilation aborted.

B. Check if the documentation of a perl module is installed.

Code:
perldoc Module::Name

e.g.

# perldoc Net::SNMP

Net::SNMP(3) User Contributed Perl Documentation Net::SNMP(3)
NAME
Net::SNMP – Object oriented interface to SNMP

without:

[root@darwin ~]# perldoc Net::Telnet

No documentation found for “Net::Telnet”.

INSTALLING PERL MODULES

1. via CPAN

(+) Open CPAN shell:

# perl -MCPAN -e shell

(+) To reconfigure the shell if needed.

cpan>o conf init

(+) Install an available module.

cpan> install Module::Name

# Force install if test fails.

cpan> force install Module::Name

2. Manual
Search and download the file in http://search.cpan.org
e.g. Time::HiRes


#wget http://search.cpan.org/CPAN/authors/id/J/JH/JHI/Time-HiRes-1.9719.tar.gz
#tar zxvf Time-HiRes-1.9719.tar.gz
# perl Makefile.PL
# make
# make test
# make install

Share

About the author

tux

View all posts

Leave a Reply