加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在Perl中使用XPath

发布时间:2020-12-16 06:08:15 所属栏目:大数据 来源:网络整理
导读:我试图使用Perl复制我的C#/ XPath代码在 Linux上的作用.我在 Perl XML中复制并粘贴了例8-6中的代码.如果我理解正确,我应该可以运行该Perl代码,将此代码放在终端中 xmlPerl.pl mydatafile.xml "/inventory/category/item/name" 但是当我尝试运行Perl文件时,它
我试图使用Perl复制我的C#/ XPath代码在 Linux上的作用.我在 Perl & XML中复制并粘贴了例8-6中的代码.如果我理解正确,我应该可以运行该Perl代码,将此代码放在终端中

xmlPerl.pl mydatafile.xml "/inventory/category/item/name"

但是当我尝试运行Perl文件时,它不起作用.这是错误:

[root@Perl ~]# perl xmlPerl.pl
Can't locate XML/XPath.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at xmlPerl.pl line 3.
BEGIN failed--compilation aborted at xmlPerl.pl line 3.

我究竟做错了什么?我认为它与我的代码开头的XML和XPath名称有关.我是否需要安装一些东西才能使用XPath框架?我在RedHat 5.5上运行.

解决方法

perldiag开始:

Can’t locate %s

You said to do (or require,or use) a file that couldn’t be found. Perl looks for the file in all the locations mentioned in @INC,unless the file name included the full path to the file. Perhaps you need to set the PERL5LIB or PERL5OPT environment variable to say where the extra library is,or maybe the script needs to add the library name to @INC. Or maybe you just misspelled the name of the file. See require in perlfunc and lib.

您没有安装XML :: XPath模块,或者Perl没有找到它.使用CPAN安装模块:

> cpan XML::XPath

或包裹经理:

> apt-get install libxml-xpath-perl

或者,如果它已经安装,说明PERL5LIB环境变量的位置:

> PERL5LIB=/path/to/lib perl ...

@INC变量:

BEGIN {
    unshift(@INC,'/path/to/lib');
}

或者lib pragma:

use lib '/path/to/lib';

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读