【问题标题】:Can't locate XML/Writer.pm in @INC [duplicate]在@INC 中找不到 XML/Writer.pm [重复]
【发布时间】:2017-07-08 18:49:51
【问题描述】:

谁能帮我排除下面的错误。

提前致谢

在@INC 中找不到 XML/Writer.pm(@INC 包含:/home/svceln/usr/lib/perl5/site_perl/5.16.2/x86_64-linux /home/svceln/usr/lib/perl5 /site_perl/5.16.2 /home/svceln/usr/lib/perl5/5.16.2/x86_64-linux /home/svceln/usr/lib/perl5/5.16.2 .) 在 /opt/apps/tomcat_scripts/allocate_ports。请在第 7 行。 BEGIN 失败——编译在 /opt/apps/tomcat_scripts/allocate_ports.pl 第 7 行中止。 分配端口出错,server.xml无法运行`

我正在使用的脚本

#!/home/svceln/usr/bin/perl -w
# allocate_ports.pl

# allocate ports, create port_config.xml and write to stdout

use strict;
use XML::Writer;
use IO::File;enter code here
use File::Basename;

my ($increment) = 0;
my ($execDir) = dirname($0);

$#ARGV eq 0 or die "Usage: allocate_ports.pl server_name\n";

my ($port_read) = new IO::File ("$execDir/port_increment.txt");
if (defined $port_read) {
  while (<$port_read>) {
    chomp;
    $increment = $_;
  }
  $port_read->close() or die "Can't close port_increment.txt: $!";
} else {
  $increment = 0;
}

【问题讨论】:

  • 看起来XML::Writer 没有安装。
  • 我只是按照以下步骤安装 perl。哪里不对了? perlmaven.com/download-and-install-perl
  • @Ragu XML::Writer 不是 perl 的一部分。它必须单独安装。
  • XML::Writer 不是 Perls 核心模块的一部分(“内置”模块几乎总是在安装 Perl 之后)。有很多方法可以安装附加模块。其中,这可能是一个好的开始:thoughtco.com/installing-perl-modules-from-cpan-2641120 也可以尝试命令:定位 XML/Writer.pm 然后将其添加为程序的第 2 行:使用 lib 'path'; #where path 是定位到但不包括字符串“XML/Writer.pm”本身的结果。

标签: perl perl-module


【解决方案1】:

它可能在一个包中,比如 libxml-writer-perl,假设是 Debian。

apt-cache search XML::Writer 如果您的系统使用 apt,则会提供软件包列表。

取决于您如何获取 perl 模块。

【讨论】:

  • 这里行不通。从@INC 中的目录列表来看,这是一个定制的perl,而不是系统perl。不过cpan XML::Writer 应该可以工作。
猜你喜欢
  • 2020-10-14
  • 2013-11-14
  • 2017-07-13
  • 1970-01-01
  • 2020-11-07
  • 1970-01-01
  • 1970-01-01
  • 2016-05-31
  • 2017-11-21
相关资源
最近更新 更多