Why this error "Can't locate object method new"? - perl

I am trying to use HTML::WikiConverter::MediaWiki which I have installed using yum install perl-HTML-WikiConverter-MediaWiki.noarch.
According to the perldoc should I be able to
use HTML::WikiConverter;
my $wc = new HTML::WikiConverter( dialect => 'MediaWiki' );
but then I get
Can't locate HTML/WikiConverter.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 .) at ./test.pl line 3.
BEGIN failed--compilation aborted at ./test.pl line 3.
If I try
use HTML::WikiConverter::MediaWiki;
my $wc = new HTML::WikiConverter( dialect => 'MediaWiki' );
then I get
Can't locate object method "new" via package "HTML::WikiConverter" at ./test.pl line 4.
If I try
use HTML::WikiConverter::MediaWiki;
my $wc = new HTML::WikiConverter::MediaWiki( dialect => 'MediaWiki' );
then I get
Can't locate object method "new" via package "HTML::WikiConverter::MediaWiki" at ./test.pl line 4.
Question
Can anyone see what's wrong?
Update
[root#rt ~]# cpan HTML::WikiConverter
Reading '/root/.cpan/Metadata'
Database was generated on Fri, 09 Mar 2012 16:12:01 GMT
Running install for module 'HTML::WikiConverter'
Running make for D/DI/DIBERRI/HTML-WikiConverter-0.68.tar.gz
Checksum for /root/.cpan/sources/authors/id/D/DI/DIBERRI/HTML-WikiConverter-0.68.tar.gz ok
CPAN.pm: Building D/DI/DIBERRI/HTML-WikiConverter-0.68.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for HTML::WikiConverter
Writing MYMETA.yml and MYMETA.json
cp lib/HTML/WikiConverter.pm blib/lib/HTML/WikiConverter.pm
cp lib/HTML/WikiConverter/Normalizer.pm blib/lib/HTML/WikiConverter/Normalizer.pm
cp lib/HTML/WikiConverter/WebApp.pm blib/lib/HTML/WikiConverter/WebApp.pm
cp lib/HTML/WikiConverter/Dialects.pod blib/lib/HTML/WikiConverter/Dialects.pod
cp bin/html2wiki blib/script/html2wiki
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/html2wiki
Manifying blib/man1/html2wiki.1
Manifying blib/man3/HTML::WikiConverter.3pm
Manifying blib/man3/HTML::WikiConverter::Normalizer.3pm
Manifying blib/man3/HTML::WikiConverter::Dialects.3pm
Manifying blib/man3/HTML::WikiConverter::WebApp.3pm
DIBERRI/HTML-WikiConverter-0.68.tar.gz
/usr/bin/make -- OK
'YAML' not installed, will not store persistent state
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-load.t ........... 1/1 # Testing HTML::WikiConverter 0.68, Perl 5.008008, /usr/bin/perl
t/00-load.t ........... ok
t/01-normalizer.t ..... ok
t/01-wikiconverter.t .. 1/53 request for <http://diberri.dyndns.org/wikipedia/html2wiki-old/test.html> failed at t/01-wikiconverter.t line 162
# Looks like you planned 53 tests but ran 35.
# Looks like your test exited with 22 just after 35.
t/01-wikiconverter.t .. Dubious, test returned 22 (wstat 5632, 0x1600)
Failed 18/53 subtests
t/boilerplate.t ....... ok
t/pod-coverage.t ...... ok
t/pod.t ............... ok
Test Summary Report
-------------------
t/01-wikiconverter.t (Wstat: 5632 Tests: 35 Failed: 0)
Non-zero exit status: 22
Parse errors: Bad plan. You planned 53 tests but ran 35.
Files=6, Tests=53, 1 wallclock secs ( 0.06 usr 0.04 sys + 0.60 cusr 0.12 csys = 0.82 CPU)
Result: FAIL
Failed 1/6 test programs. 0/53 subtests failed.
make: *** [test_dynamic] Error 255
DIBERRI/HTML-WikiConverter-0.68.tar.gz
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports DIBERRI/HTML-WikiConverter-0.68.tar.gz
Running make install
make test had returned bad status, won't install without force
[root#rt ~]#

You don't have HTML::WikiConverter installed. So, install it. From the command line, do
cpan HTML::WikiConverter
and not only will HTML::WikiConverter be installed, but any missing prerequisites should be installed as well.
Also, depending your user permissions, you may need to run that command as root (ie sudo cpan HTML::WikiConverter).

It sounds like you don't have the base behavior HTML::WikiConverter installed in a place where you need it. I don't know why the use base in HTML::WikiConverter::MediaWiki isn't failing, though. HTML::WikiConverter is a separate distribution from HTML::WikiConverter::MediaWiki and HWM uses HW's constructor, so it makes sense that if you can't load this module, Perl does not recognize a dispatch for new.

When you ran yum install perl-HTML-WikiConverter-MediaWiki.noarch did you get any output that mentioned installing perl-HTML-WikiConverter?
What output do you get from running rpm -q perl-HTML-WikiConverter and rpm -q perl-HTML-WikiConverter-MediaWiki.
Which version of Perl are you running (perl -v), where is it installed (which perl) and how was it installed (using yum or by downloading source code and compiling it)?
I suspect your system is getting confused between yum-installed CPAN modules and cpan-install CPAN modules. It's never a good idea to mix the two on the same system. If you want to use the system version of Perl then only install CPAN modules using yum. If you want to install CPAN modules using cpan (or cpanp or cpanm) then build your own version of Perl and install it away from the standard Perl location.

Related

Failed installation of Archive::Extract with Cpan

I have installed ActivePerl in order to run a bioinformatic tool.
after running the tool on Windows PowerShell I got this message:
Perl module Archive::Extract (in core since 2007-07-07) is not installed on this machine!
Perl modules are available for download at http://www.cpan.org/
If you have CPAN installed try the following: cpan install
Archive::Extract exit
If you are on Mac or Unix you should run cpan with sudo: sudo cpan
install Archive::Extract exit
So I tried to install it:
cpan
install Archive::Extract
and got this:
"C:\Perl64\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/.t
t/01_Archive-Extract.t .. # Older versions of Archive::Zip may cause File::Spec warnings
See bug #19713 in rt.cpan.org. It is safe to ignore them
t/01_Archive-Extract.t .. 87/?
As I'm not adept at this I thought that I should try to install again the Archive::Zip
install Archive::Zip
but I got :
t/25_traversal.t .............. 1/41
Failed test 'Tree extraction aborted'
at t/25_traversal.t line 97.
got: '0'
expected: '2'
Looks like you failed 1 test of 41.
t/25_traversal.t .............. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/41 subtests
(less 32 skipped subtests: 8 okay)
Test Summary Report
t/25_traversal.t (Wstat: 256 Tests: 41 Failed: 1)
Failed test: 16
Non-zero exit status: 1
Files=25, Tests=346, 18 wallclock secs ( 0.19 usr + 0.13 sys = 0.31 CPU)
Result: FAIL
Failed 1/25 test programs. 1/346 subtests failed.
dmake.exe: Error code 129, while making 'test_dynamic'
Could you please explain what's the particular problem in order to understand it and how can I solve it?
I don't know if it's a naive question as I have just started learning about command line tools, Linux, Perl etc.
Active Perl uses the ppm script to install modules, mixing this with cpan can cause the problems you have seen above. You may find that using Strawberry Perl works better for you as this comes with a c compiler that will allow you to install non pure Perl modules from cpan

trouble installing Tkx perl module in Ubuntu 14.04

In order to install a package called PrimerMapper for designing primers on Ubuntu 14.04, I need to install a perl module called Tkx but facing trouble in installing it. So, kindly assist me in resolving this bug.
For your quick and easy reference, I am pasting complete commands of installation. Thanks a lot
**adnan#adnan-Inspiron-N5110[Tkx-1.09]** sudo perl Makefile.PL
Writing Makefile for Tkx
Writing MYMETA.yml and MYMETA.json
**adnan#adnan-Inspiron-N5110[Tkx-1.09]** sudo make
Skip blib/lib/Tkx/Tutorial.pod (unchanged)
Skip blib/lib/Tkx.pm (unchanged)
Skip blib/lib/Tkx/MegaConfig.pm (unchanged)
Skip blib/lib/Tkx/LabEntry.pm (unchanged)
cp tkx-prove blib/script/tkx-prove
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/tkx-prove
cp tkx-ed blib/script/tkx-ed
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/tkx-ed
Manifying blib/man1/tkx-ed.1p
Manifying blib/man3/Tkx::MegaConfig.3pm
Manifying blib/man3/Tkx::LabEntry.3pm
Manifying blib/man3/Tkx::Tutorial.3pm
Manifying blib/man3/Tkx.3pm
**adnan#adnan-Inspiron-N5110[Tkx-1.09]** sudo make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/LabEntry.t ...... 1/2 (in cleanup) Can't call method "DeleteCommand" on an undefined value at /usr/local/lib/perl/5.18.2/Tcl.pm line 655 during global destruction.
t/LabEntry.t ...... ok
t/mega-config.t ... ok
t/mega.t .......... ok
t/nul-char.t ...... ok
t/tcl-callback.t .. 1/7 (in cleanup) Can't call method "DeleteCommand" on an undefined value at /usr/local/lib/perl/5.18.2/Tcl.pm line 655 during global destruction.
t/tcl-callback.t .. ok
t/tcl.t ........... 1/18 # Test 18 got: "Tcl error 'Foo at /usr/local/lib/perl/5.18.2/Tcl.pm line 585.\n' while invoking scalar result call:\n\t\"error Foo\" at /usr/local/lib/perl/5.18.2/Tcl.pm line 588.\n\tTcl::call('Tcl=SCALAR(0x1b2ce48)', 'error', 'Foo') called at /media/windows/NGS/GATK_FINAL_PIPELINE/PrimerMapper-master/Tkx-1.09/blib/lib/Tkx.pm line 329\n\teval {...} called at /media/windows/NGS/GATK_FINAL_PIPELINE/PrimerMapper-master/Tkx-1.09/blib/lib/Tkx.pm line 329\n\tTkx::i::call('error', 'Foo') called at /media/windows/NGS/GATK_FINAL_PIPELINE/PrimerMapper-master/Tkx-1.09/blib/lib/Tkx.pm line 51\n\tTkx::AUTOLOAD('Foo') called at t/tcl.t line 38\n\teval {...} called at t/tcl.t line 38\n" (t/tcl.t at line 39)
# Expected: "Foo at t/tcl.t line 38.\n"
# t/tcl.t line 39 is: ok($#, "Foo at #{[__FILE__]} line #{[__LINE__ - 1]}.\n");
t/tcl.t ........... Failed 1/18 subtests
t/tk.t ............ 12/12 (in cleanup) Can't call method "DeleteCommand" on an undefined value at /usr/local/lib/perl/5.18.2/Tcl.pm line 655 during global destruction.
t/tk.t ............ ok
t/utf8.t .......... ok
Test Summary Report
-------------------
t/tcl.t (Wstat: 0 Tests: 18 Failed: 1)
Failed test: 18
Files=8, Tests=54, 9 wallclock secs ( 0.15 usr 0.03 sys + 1.85 cusr 0.31 csys = 2.34 CPU)
Result: FAIL
Failed 1/8 test programs. 1/54 subtests failed.
make: *** [test_dynamic] Error 255
GAAS/Tkx-1.09.tar.gz
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports GAAS/Tkx-1.09.tar.gz
Running make install
make test had returned bad status, won't install without force
Failed during this command:
GAAS/Tkx-1.09.tar.gz : make_test NO
The error is that the tests of the module don't pass successfully.
One thing I would try first is to try to install the module with cpan or cpanminus (cpan Tkx or cpanm Tkx). You (or the Makefile.PL) may have missed something that could be causing this error.
I see you already opened a bug report on CPAN. You can see in cpantesters that this module has the tests broken (you could check with your particular Perl version) and there is also another bug report from 5 years ago reporting broken tests for the very same version that's currently on CPAN (1.09).
Considering this I think your options is to skip the tests and see if it works for your purposes.
I recently adopted Tkx and published release 1.10, which allows installation to proceed despite the t/tcl.t test 18 failure.
The test failure appears to have been caused by unexpected but minor changes to error message formatting in newer Tcl.pm. Pending the issue actually being fixed, it is not something which Tkx should abort installation over.
There's already a packaged version of Tkx for Ubuntu, so all it should take to get Tkx and any of its dependencies is:
sudo apt-get install libperl-tkx

Undefined subroutine Win32::MSgBox when trying to install Win32::Watir on Strawberry Perl

I am trying to install Win32::Watir on to a 64 bit machine via strawberry perl. I'm getting an error. This is a windows automation tool - so it should have be to be able to be installed on a windows machine via strawberry perl.
reports SHIMI/Win32-Watir-0.06-withoutworldwritebles.tar.gz
cpan> install Win32::Watir
Fetching with LWP:
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/02packages.details.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/03modlist.data.gz
Database was generated on Wed, 29 Jul 2015 22:17:00 GMT
Updating database file ...
Done!
Running install for module 'Win32::Watir'
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/S/SH/SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/S/SH/SHIMI/CHECKSUMS
Checksum for C:\UBS\DEV\STRAWB~1\cpan\sources\authors\id\S\SH\SHIMI\Win32-Watir-0.06-withoutworldwriteables.tar.gz ok
Scanning cache C:\UBS\DEV\STRAWB~1\cpan\build for sizes
............................................................................DONE
Configuring S/SH/SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a dmake-style Makefile
Writing Makefile for Win32::Watir
Writing MYMETA.yml and MYMETA.json
SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
C:\UBS\DEV\Strawberry\perl\bin\perl.exe Makefile.PL -- OK
Running make for S/SH/SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
cp lib/Win32/Watir/Table.pm blib\lib\Win32\Watir\Table.pm
cp lib/Win32/Watir/AutoItX3.dll blib\lib\Win32\Watir\AutoItX3.dll
cp lib/Win32/Watir.pm blib\lib\Win32\Watir.pm
cp lib/Win32/Watir/AutoItX.chm blib\lib\Win32\Watir\AutoItX.chm
cp lib/Win32/Watir/AutoItX3_x64.dll blib\lib\Win32\Watir\AutoItX3_x64.dll
cp lib/Win32/Watir/Element.pm blib\lib\Win32\Watir\Element.pm
SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
C:\UBS\DEV\STRAWB~1\c\bin\dmake.exe -- OK
Running make test
"C:\UBS\DEV\Strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest: :Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.tt/01.IE_default.t .. 1/? DEBUG:_check_os_name(): Win7
Undefined subroutine &Win32::MSgBox called at
C:\UBS\DEV\STRAWB~\cpan\build\Win32-Watir-0.062RxegT\blib\lib/Win32/Watir.pm line 1370.
# Looks like your test exited with 255 just after 1.
t/01.IE_default.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
All 1 subtests passed
Test Summary Report
-------------------
t/01.IE_default.t (Wstat: 65280 Tests: 1 Failed: 0)
Non-zero exit status: 255
Files=1, Tests=1, 2 wallclock secs ( 0.02 usr + 0.11 sys = 0.13 CPU)
Result: FAIL
Failed 1/1 test programs. 0/1 subtests failed.
dmake.exe: Error code 255, while making 'test_dynamic'
SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
C:\UBS\DEV\STRAWB~1\c\bin\dmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
Stopping: 'install' failed for 'Win32::Watir'.
Failed during this command:
SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz: make_test NO
cpan> sudo install Win32::Watir
Unknown shell command 'sudo'. Type ? for help.
cpan>
The module calls Win32::MSgBox when it should have called Win32::MsgBox.

Compiling Statistics::Basic on strawberry failed

Running a tool, I had to install Perl. Well, I've installed Strawberry-Perl and some modules fine. But when I make Statistics::Basic, it fails.
The process to make the module:
perl Makefile.PL (OK)
dmake test (FAIL)
C:\Perl\perl\lib\Basic>dmake test C:\Perl\perl\bin\perl.exe
"-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib\lib',
'blib\arch')" t/*.t t/05_load_them.t ................... # Test 1 got:
"Can't locate Number/Format.pm in #INC (you may need to install the
Number::Format module ) (#INC contains:
C:\Perl\perl\lib\Basic\blib\lib
C:\Perl\perl\lib\Basic\blib\arch C:/Perl/perl/site/lib
C:/Perl/perl/vendor/lib C:/Perl/perl/lib .) at
C:\Perl\perl\lib\Basic\blib\lib/Statistics/Basic.pm line
8.\nBEGIN failed--compilation aborted at C:\Perl\pe rl\lib\Basic\blib\lib/Statistics/Basic.pm line 8.\nCompilation
failed in require at
C:\Perl\perl\lib\Basic\blib\lib/Statistics/Bas
ic/_OneVectorBase.pm line 7.\nBEGIN failed--compilation aborted at
C:\Perl\perl\lib\Basic\blib\lib/Statistics/Basic/_OneVectorBase.pm
line 7.\nCompilation failed in require at (eval 1) line 2.\nBEGIN
failed--compilation aborted at (eval 1) line 2.\n" (t/05_load_them.t
at li ne 12) t/05_load_them.t ................... 1/12 # Expected: "" #
t/05_load_them.t line 12 is: ok($#, "");
. . .
I don't know Perl and I have no idea about the problem. How can I install this module?
The error message says
you may need to install the Number::Format module
So do this first. As there could be more dependencies, it's usually better to use a tool which is automatically resolving all dependencies, e.g. CPAN.pm:
cpan Statistics::Basic
I've got the same problem with the module Statistics::Basic, so tried to install Number::Format and again problem dmake test failed!
So I've just tried make install command, and then install modules, and it works.
I am in Windows. It is solved by executing dmake install manually.
# install will be failed but you can get source downloaded
> cpan install Number::Format
> cd c:\strawberry\cpan\build
# replace [version] and [random string] with what you see in the directory
> cd Number-Format-[version]-[random string]
# ignore `dmake test`
> dmake install

Installing perl switch using CPAN is failing

I pasted the output below (originally posted to http://pastebin.com/Sh7a8tHK)
cpan[1]> install Switch
Reading '/.cpan/Metadata'
Database was generated on Tue, 11 Dec 2012 05:55:05 GMT
Running install for module 'Switch'
Running make for R/RG/RGARCIA/Switch-2.16.tar.gz
Checksum for /.cpan/sources/authors/id/R/RG/RGARCIA/Switch-2.16.tar.gz ok
Scanning cache /.cpan/build for sizes
............................................................................DONE
CPAN.pm: Building R/RG/RGARCIA/Switch-2.16.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Switch
Writing MYMETA.yml and MYMETA.json
cp Switch.pm blib/lib/Switch.pm
Manifying blib/man3/Switch.3
RGARCIA/Switch-2.16.tar.gz
/usr/ccs/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /opt/perl/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/given.t ... Useless use of numeric gt (>) in void context at t/given.t line 19.
t/given.t ... Failed 2/293 subtests
t/nested.t .. ok
t/switch.t .. ok
Test Summary Report
-------------------
t/given.t (Wstat: 0 Tests: 293 Failed: 2)
Failed tests: 2-3
Files=3, Tests=590, 1 wallclock secs ( 0.07 usr 0.01 sys + 0.47 cusr 0.00 csys = 0.55 CPU)
Result: FAIL
Failed 1/3 test programs. 2/590 subtests failed.
*** Error code 255
make: Fatal error: Command failed for target `test_dynamic'
RGARCIA/Switch-2.16.tar.gz
/usr/ccs/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports RGARCIA/Switch-2.16.tar.gz
Running make install
make test had returned bad status, won't install without force
Failed during this command:
RGARCIA/Switch-2.16.tar.gz : make_test NO
cpan[2]>
There seems to be a problem with the module as evidenced by "Useless use of numeric gt.....", however I installed this module fine on a different machine using CPAN. This is the only module CPAN is complaining about when installing.
I am using the latest version of perl 5.16:
This is perl 5, version 16, subversion 2 (v5.16.2) built for i86pc-solaris
How can I install this module?
NOTE: Please do not tell me Switch is deprecated. I understand that.
Try doing this :
use feature qw/switch/;
See
perldoc -q switch
Refer to The Effective Perler article Use for() instead of given() if you're OK to use Perl v5.10 or later.
Patch:
--- Switch-2.16-wjgfvU/Switch.pm 2009-10-23 00:52:51.000000000 -0700
+++ Switch-2.16-wjgfvUcopy/Switch.pm 2010-08-15 17:41:38.000000000 -0700
## -146,7 +146,7 ## sub filter_blocks
die "Bad $keyword statement (problem in the code block?) near $Switch::file line ", line(substr($source,0, pos $source), $line), "\n";
};
my $code = filter_blocks(substr($source,$pos[0],$pos[4]-$pos[0]),line(substr($source,0,$pos[0]),$line));
- $code =~ s/{/{ local \$::_S_W_I_T_C_H; Switch::switch $arg;/;
+ $code =~ s/{/{ local \$::_S_W_I_T_C_H; Switch::switch($arg);/;
$text .= $code . 'continue {last}';
next component;
}