我将 perl 模块安装在~/.local/perl5
. 以下是部分内容~/.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
但是当我use
- 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();
如果我use 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();