Perl无法找到XML / Simple.pm

时间:2016-09-13 18:04:49

标签: perl ubuntu

我正在研究Perl,当我运行我的脚本时,我得到错误说:

Can't locate XML/Simple.pm in @INC (you may need to install the  XML::Simple module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at cve_updater.pl line 43.

我搜索问题并得到更新或安装模块的答案。我同时使用两者:

cpan XML::DOM
cpan[1]> install XML::Simple

但结果如下:

Reading '/root/.cpan/Metadata'
Database was generated on Tue, 14 Jun 2016 19:53:39 GMT
Fetching with LWP:
http://CPAN.mirror.rafal.ca/authors/01mailrc.txt.gz
LWP failed with code[500] message[Can't connect to CPAN.mirror.rafal.ca:80]

Trying with
/usr/bin/wget -O "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822"
to get
http://CPAN.mirror.rafal.ca/authors/01mailrc.txt.gz
--2016-09-13 13:31:39--  http://cpan.mirror.rafal.ca/authors/01mailrc.txt.gz
Resolving cpan.mirror.rafal.ca (cpan.mirror.rafal.ca)... failed: Name or service not known.
wget: unable to resolve host address âcpan.mirror.rafal.caâ

Function system("/usr/bin/wget -O "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822" "http://CPAN.mirror.rafal.ca/authors/01mailrc.txt.gz" ")
returned status 4 (wstat 1024), left
/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822 with size 0
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822'. Giving up on it.
Fetching with LWP:
http://cpan.erlbaum.net/authors/01mailrc.txt.gz
LWP failed with code[500] message[Can't connect to cpan.erlbaum.net:80]

Trying with
/usr/bin/wget -O "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822"
to get
http://cpan.erlbaum.net/authors/01mailrc.txt.gz
--2016-09-13 13:31:39--  http://cpan.erlbaum.net/authors/01mailrc.txt.gz
Resolving cpan.erlbaum.net (cpan.erlbaum.net)... failed: Name or service not known.
wget: unable to resolve host address âcpan.erlbaum.netâ

Function system("/usr/bin/wget -O "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822" "http://cpan.erlbaum.net/authors/01mailrc.txt.gz" ")
returned status 4 (wstat 1024), left
/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822 with size 0
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp28822'. Giving up on it.
Fetching with LWP:
http://mirrors.ccs.neu.edu/CPAN/authors/01mailrc.txt.gz

我无法理解这是什么问题,感谢任何帮助和评论。

1 个答案:

答案 0 :(得分:2)

您已经获得了有关使CPAN安装正常工作的注释的帮助,但是大多数常见的Perl模块也可以从Ubuntu存储库安装。在这种情况下,您还应该能够sudo apt-get install libxml-simple-perl从Ubuntu安装它。如果这不是正确的软件包名称(我使用的是Debian而不是Ubuntu,那么Ubuntu可能已将其重命名),您可以使用apt-cache search XML::Simple获取匹配软件包的列表,然后用apt-cache show [package name]检查他们的详细信息,以确定您想要的那个。

但请注意,XML::Simple文档建议"您真的不想在新代码中使用此模块。" 如果您是编写新代码时,您应该查看另一个XML模块。我个人使用XML::Twig,恰好提供了一个simplify方法,它产生的输出非常类似于XML :: Simple,尽管你可能最好习惯更健壮的节点 - 基于界面。