Perl的一些小知识点


之前曾简单的写/改写过几个Perl脚本,现在又碰到一个Perl写的脚本,于是先快速学习一下 Perl的相关知识。

搜索关键字:
  • perl 快速 学习
  • perl 教程
  • perl tutorial
  • Perl 打印字符串
  • Perl 注释
  • Can’t locate Net/LDAP.pm in @INC #AOL&Baidu搜索
在Linux下如何安装在Perl脚本里用到的模块?

Can’t locate Net/LDAP.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./xxx.pl line 40.
BEGIN failed–compilation aborted at ./xxx.pl line 40.

方法一:直接yum search/install试试
$ perl -MCPAN -e shell
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

$ sudo yum search perl-CPAN
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
============================================= N/S Matched: perl-CPAN ==============================================
perl-CPAN.x86_64 : Query, download and build perl modules from CPAN sites
perl-CPANPLUS.x86_64 : API & CLI access to the CPAN mirrors

  Name and summary matches only, use "search all" for everything.
$ sudo yum search perl-LDAP
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
============================================= N/S Matched: perl-LDAP ==============================================
perl-LDAP.noarch : LDAP Perl module

  Name and summary matches only, use "search all" for everything.
方法二:CPAN或源码编译安装

The scripts outputs “Can’t locate Net/SNMP.pm in @INC…..”
You don’t have Net::SNMP installed, see below
How do I install Net::SNMP perl module ?
There are 2 ways of doing this

1) By CPAN (best)

on command line, as root :

[your_host]# perl -MCPAN -e shell
cpan shell -> CPAN exploration and modules installation (v1.76)
ReadLine support enabled
cpan> install Net::SNMP
If it's the first time you run CPAN, it will probably ask you some (simple) questions.
CPAN will also ask you to satisfy some dependencies (Crypt::DES, Digest::MD5, etc..).

2) “By hand”

Get the folowings modules (tar.gz format) on www.cpan.org
– Crypt::DES
– Digest::MD5
– Digest::SHA1
– Digest::HMAC
– Net::SNMP

for each one (you must install Net::SNMP at the end) :

tar zxf <module>.tar.gz
cd <module>
perl Makefile.pl
make test
make install

 

参考链接:

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注