Adobe Adobe - 6 months ago 18
Perl Question

Can't locate *** in @INC

I install perl modules in

~/.local/perl5
. Here's part of
~/.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";


I've installed
CSS::Inliner
with

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


and I have
Inliner.pm
at:

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


But when I
use
it -- perl can't find it:

perl -e 'use Inliner'


gives:

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.


why can't perl find the module?

Edit:

I'm trying to reproduce minimal working example given in documentation to CSS-Inliner:

use Inliner;

my $inliner = new Inliner();

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

print $inliner->inlinify();


If I
use Inliner
-- perl can't find it. If I

#!/usr/bin/perl

use CSS::Inliner;

my $inliner = new Inliner();

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

print $inliner->inlinify();


perl says

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


Edit 2:

Here's a minimal working example of
CSS-Inliner
:

#!/usr/bin/perl

use CSS::Inliner;

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

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

print $inliner->inlinify();

Answer

You should use the full module name in use and full class name when calling class methods:

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