在perl版本v5.10.0中使用telnet出现这样的错误?

在perl版本v5.10.0中使用telnet出现这样的错误?

有这样一段perl代码,是telnet连接代码,如下:

#!/usr/bin/perl -w

use Net::Telnet ();

$timeout = 20;
$port = 23;
$host = '192.168.1.251';
$user = 'test';
$pw = '123456';

$t = new Net::Telnet (Timeout => $timeout,
                      Port    => $port);
$t->open($host);
$t->login($user, $pw);
@lines = $t->cmd("who");
print @lines;

运行这段代码,出现如下错误:

[root@localhost aa]# ./connect_telnet.pl
Can't locate Net/Telnet.pm in @INC (@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at ./connect_telnet.pl line 4.
BEGIN failed--compilation aborted at ./connect_telnet.pl line 4.


perl的版本是v5.10.0,请问这是什么原因引起的,是不是在v5.10.0中不支持telnet?
Can't locate Net/Telnet.pm
模块都没装把
如何检查模块是否安装?

我执行下面的命令,没有错误提示:

[root@localhost aa]# perl -e 'use Net::Telnet'
[root@localhost aa]#

通过实验,这段程序在perl版本5.8.5下面可以顺利执行,奇怪?
看看Net::Telnet模块是否在@INC目录里


QUOTE:
原帖由 hfahe 于 2008-10-8 16:49 发表
看看Net::Telnet模块是否在@INC目录里

这位兄弟,谢谢你的回复,速度真快,但是我还是不知道如何查看“Net::Telnet模块是否在@INC目录里”?
能否说的详细点,谢谢!
perldoc -l Net::Telnet
看具体的位置
然后再看看是否在@INC里面


QUOTE:
原帖由 churchmice 于 2008-10-8 18:33 发表
perldoc -l Net::Telnet
看具体的位置
然后再看看是否在@INC里面

[root@localhost Net]# perldoc -l Net::Telnet
/usr/local/lib/perl5/site_perl/5.10.0/Net/Telnet.pm,

这位兄弟,如何查看 是否在@INC里面?,请指点,小弟刚接触perl。
这种情况我也遇到过,我是因为没有读的权限
但是我看到你是root下运行的,具体原因就不知道了,除非能ssh到你机器上看看
你telnet的模块在/usr/local/lib/perl5/site_perl/5.10.0/Net/Telnet.pm
但是你perl的搜索模块路径里面没有这个路径啊
(@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .)
落叶季节,思念季节
你用5.10.0的话下面的命令可以列出模块的搜索路径:

perl -E 'say for @INC'
落叶季节,思念季节