perl - 在 @INC 中找不到 ***

标签 perl

我在~/.local/perl5中安装perl模块。这是~/.bashrc的一部分:

export PERL_LOCAL_LIB_ROOT="$HOME/.local/perl5";
export PERL_MB_OPT="--install_base $HOME/.local/perl5";
export PERL_MM_OPT="INSTALL_BASE=$HOME/.local/perl5";
export PERL5LIB="$HOME/.local/perl5/lib/perl5:$PERL5LIB";
export PATH="$HOME/.local/perl5/bin:$PATH";

我已经安装了 CSS::Inliner

$ cpan
cpan[1]> install CSS::Inliner

我有 Inliner.pm 位于:

~/.local/perl5/lib/perl5/CSS/Inliner.pm

但是当我使用它时——perl找不到它:

perl -e 'use Inliner'

给出:

Can't locate Inliner.pm in @INC (@INC contains:
/home/boris/.local/perl5/lib/perl5/x86_64-linux-gnu-thread-multi
/home/boris/.local/perl5/lib/perl5 /etc/perl
/usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14
/usr/local/lib/site_perl .) at -e line 1. BEGIN failed--compilation
aborted at -e line 1.

为什么perl找不到模块?

编辑:

我正在尝试重现 CSS-Inliner 文档中给出的最小工作示例:

use Inliner;

my $inliner = new Inliner();

$inliner->read_file({filename => 'myfile.html'});

print $inliner->inlinify();

如果我使用 Inliner——perl 找不到它。如果我

#!/usr/bin/perl

use CSS::Inliner;

my $inliner = new Inliner();

$inliner->read_file({filename => 'test.html'});

print $inliner->inlinify();

perl 说

Can't locate object method "new" via package "Inliner"
(perhaps you forgot to load "Inliner"?) at ./1.perl line 5.

编辑 2:

这是 CSS-Inliner 的最小工作示例:

#!/usr/bin/perl

use CSS::Inliner;

my $inliner = CSS::Inliner->new;

$inliner->read_file({filename => 'test.html'});

print $inliner->inlinify();

最佳答案

您应该在use中使用完整的模块名称,并在调用类方法时使用完整的类名称:

use CSS::Inliner;
my $inliner = CSS::Inliner->new;

关于perl - 在 @INC 中找不到 ***,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15403239/

相关文章:

perl - 如何在 Perl 中实现一个简单的 IRC 客户端?

perl - Mojolicious 源 IP 和用户代理

perl - 是否可以使用两个键和值来合并多个文件?

perl - 使用 Test::WWW::Selenium 或其他方式检测操作系统对话框

c++ - C/C++ 或其他语言中的 SOCKS?

perl - 翻译 perl 脚本删除脚本 (1) 输出中的控制字符到 sed

linux - LongReadLen 的 Perl DBI 替代品

将十六进制数数组转换为 unsigned char* for Inline::C

dbi - [perl]如何强制perl在我自己的路径中使用模块?

perl - 正在安装模块(不是?),因为它是最新的(是吗?)