Trouble With CPAN Module - perl

I've tried to install the WWW::Mechanize module with
'cpan WWW::Mechanize'
I get no errors on the 'use WWW::Mechanize' line which means its finding the files, but upon trying to instantiate it with:
$m = WWW::Mechanize->new();
I get the following problem:
Can't locate HTTP/Config.pm in #INC (#INC contains: /Library/Perl/Updates/5.10.0/darwin- thread-multi-2level /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at /Library/Perl/5.10.0/LWP/UserAgent.pm line 746.
I'm not exactly sure what is going on. I feel like I have all the neccessary dependencies, but I can't seem to find what this particular error means.
My script is empty besides the previously mentioned lines and
use strict;
use warnings;
Has anyone run into this?

try installing it with the following command (from the shell):
perl -MCPAN -e 'install WWW::Mechanize'
follow the installation process, and answer 'Y' where needed.

Related

utf8::all on perl-5.12.3 doesn't work and I can't uninstall it

On Mac OS X 10.7.5 on which perl-5.12.3 is installed, I needed to use the utf8::all module so I have manually installed utf8-all-0.024 (Note the minimum perl version of v5.10.0 on its CPAN page) The make test has failed but I've still installed it to see if it would work. It didn't work so I've decided to uninstall it. I've tried 2 methods given at perl.com the first method didn't work as it required perl-5.14.2 The second method gave this message:
! utf-8 is not found in the following directories and can't be uninstalled.
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
and it couldn't uninstall it either. How to uninstall the utf8-all-0.024?
Furthermore, I had a small script listing all the Perl modules. It is:
use ExtUtils::Installed;
my $inst = ExtUtils::Installed->new();
my #modules = $inst->modules();
foreach $module (#modules) {
print $module . "\n";
}
This script started to take about a minute and half of the CPU time, to list the modules. Before I messed up the system, it was giving instant result. How to rectify it?
For the sake of completeness here is the #INC as given by the perl -V
#INC:
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
/Network/Library/Perl/5.12/darwin-thread-multi-2level
/Network/Library/Perl/5.12
/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.3
/System/Library/Perl/5.12/darwin-thread-multi-2level
/System/Library/Perl/5.12
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.12
.
Further info:
perl -Mutf8::all -e 'print $INC{"utf8/all.pm"}, "\n"' gives:
Can't locate Import/Into.pm in #INC (#INC contains: /Library
/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network
/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library
/Perl/5.12 /Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.3 /System/Library/Perl/5.12/darwin-
thread-multi-2level /System/Library/Perl/5.12 /System/Library
/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library
/Perl/Extras/5.12 .) at /Library/Perl/5.12/utf8/all.pm line 140.
BEGIN failed--compilation aborted at /Library/Perl/5.12/utf8/all.pm line 140.
Compilation failed in require.
BEGIN failed--compilation aborted.
You've made a mess of things by incorrectly installing the module. Specifically, you didn't install the dependencies.
Ideally, you should use the package manager that provided perl itself. But they don't provide every module. So you'd use the non-package manager approach:
cpan utf8::all
(I prefer to install my own perl using perlbrew, then I can use cpan without worry.)
Now, cpan might claim that utf8::all is already installed. If so, this should get you straightened out:
cpan -t utf8::all
cpan -f utf8::all # Only if the previous command says everything is ok!

Can't locate XML/LibXML.pm in #INC

I am trying to run script which uses XML/LibXML package.
But, XML/LibXML package is already installed. I ran following command:
perl -MXML::LibXML -e 1. it did not give any output, that means this package is installed.
when i ran my script. Following error occured.
Can't locate XML/LibXML.pm in #INC (#INC contains:
/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8
.). BEGIN failed--compilation aborted.
One more point to note is there is no directory "5.8.8" under /usr/lib64/perl5/site_perl/
Please suggest to overcome this issue.
There are three possibilities:
You have two installs of perl and you script is using the "wrong" one.
Either install XML::LibXML using the perl used by the script, or replace the script's shebang (#!) line with the output of the following:
perl -MXML::LibXML -le'print "#!".$^X'
Differences in the environment.
If XML::LibXML was installed in a nonstandard directory, it could be that PERL5LIB was used to communicate this to perl when you executed your test, but not when you run the script.
A permission issue.
This isn't very likely.
If the script is run as the same user as your test, it's not a permission issue.
If it is a permission issue, make sure the library directory is accessible to the user executing the script.

Problems with ROUGE on Windows

I am trying to use ROUGE on Windows:
So the first few lines of the file:
use XML::DOM;
use DB_File;
use Getopt::Std;
#-------------------------------------------------------------------------------------
use vars qw($opt_a $opt_b $opt_c $opt_d $opt_e $opt_f $opt_h $opt_H $opt_m $opt_n $opt_p $opt_s $opt_t $opt_l $opt_v $opt_w $opt_2 $opt_u $opt_x $opt_U $opt_3 $opt_M $opt_z);
And it gives me this error:
Can't locate DB_File.pm in #INC (#INC contains: C:/Perl64/site/lib C:/Perl64/lib
.) at C:\RELEASE-1.5.5\ROUGE-1.5.5.pl line 174.
BEGIN failed--compilation aborted at C:\RELEASE-1.5.5\ROUGE-1.5.5.pl line 174.
I am new to perl. All i need is ROUGE to work. What does this mean? How can i fix it?
The author of the perl script probably did not test his script
on windows.
You could probably hack the script to make it work, but
since you're new to perl and seem to be in a hurry,
I suggest you use linux/unix for ROGUE.
The README for ROGUE mentions linuxy things like bash etc,
which is a clue.
If you insist, here's a way to get the perl script running
on windows, but be warned, further errors can pop up
as you get deeper in to the features.
remove activeperl
install strawberryperl 32bit
cpan install XML:DOM
cpan install DB_File
try:
close existing windows
open a new command prompt
run this command
ppm install DB_File
close window
try running rogue again
hope it helps
---
if you have a copy of the rogue application please share it so we can check it out.

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();
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;
This could happen when you are not careful in installing modules. Once I simply copied the foo.pm into the official /usr/lib/perl5/site_perl directory. The foo.pm could be modules developed locally or third party. I did not pay attention to the umask. Files installed there are not readable by the world. When I use the module I will get the message saying: Cannot locate foo.pm in #INC(#INC contains /usr/lib/perl5/site_perl ....). Gee it is clearly there! Took me a while to check the file permission. Hope this may save some time for others who install their own modules. In make file you should use install -m 644 to make sure the installed module has read permission for others.

Why I can't run perl from Textmate?

#!/usr/bin/perl -w
use WWW::Mechanize;
print $WWW::Mechanize::VERSION."\n";
1) run from Textmate :
Can't locate WWW/Mechanize.pm in #INC (#INC contains:
/Applications/TextMate.app/Contents/SharedSupport/Bundles/Perl.tmbundle/Support
/Library/Perl/Updates/5.10.0
/System/Library/Perl/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/5.10.0
/Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0
/Network/Library/Perl/5.10.0/darwin-thread-multi-2level
/Network/Library/Perl/5.10.0 /Network/Library/Perl
/System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.10.0 .) at
/Users/xxx/Development/test.pl line 2. BEGIN failed--compilation
aborted at /Users/xxx/Development/test.pl line 2.
2) run from terminal:
sh-3.2# perl test.pl<br>
1.64
What should I do?
It appears you installed WWW::Mechanize into a directory that isn't searched by default. Most likely, you have a PERL5LIB or other environment variable that adds that directory to Perl's search path, and for some reason that's not set in the environment TextMate provides.
Try running perl -V from the shell and from TextMate and see what the difference in search paths is. You can also add
print "$INC{'WWW/Mechanize.pm'}\n";
to your test script to find out where it's installed.