Can't use an array as a reference when installing perl module - perl

edit: worked with sudo cpanm Data::Match --force
I'm trying to install the "Data::Match" perl module with ubuntu 18.04.
I use:
perl Makefile.pl
make
make test
And I get the following error:
make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
1..1
# Running under perl version 5.026001 for linux
# Current time local: Wed Jun 29 18:41:13 2022
# Current time GMT: Wed Jun 29 15:41:13 2022
# Using Test.pm version 1.30
Can't use an array as a reference at blib/lib/Data/Match.pm line 968.
Compilation failed in require at test.pl line 10.
BEGIN failed--compilation aborted at test.pl line 10.
Makefile:825: recipe for target 'test_dynamic' failed
make: *** [test_dynamic] Error 255
I installed many other modules and they all worked perfectly fine.
I also tried installing with
perl -MCPAN -e shell
and that didn't help.
What should I do?

The Data::Match module has some syntax that Perl v5.22 tightened up. That's why it fails. Note that force installing a module with an egregious problem like that means it will just fail when you run your program.
If you can, don't use this module. I have no idea what it does, so I don't have any suggestions for a replacement.
Let's suppose you need this module for whatever reason, even though it's 20 years old. Perhaps you're supporting a legacy app that you just need to get working.
There's this line (L968) which dereferences an array element that is itself an array reference:
$str .= $sep . '{' . join(',', #$ind->[0]) . '}';
That should be the circumfix notation to delimit the reference part:
$str .= $sep . '{' . join(',', #{$ind->[0]}) . '}';
If you make that change to Match.pm before you run perl Makefile.PL, the tests pass (but with a warning) and you can install the module.
If that's all you need, you can stop here.
Distroprefs
CPAN.pm has a way to handle these situations so you don't have to make the change every time that you want to install the module. Before CPAN.pm does its work, it can patch the problem distribution, suggest a replacement distro, or many other things. You do this with "distroprefs". There are many examples in the CPAN.pm repo.
There are a few things to set up. First, set up your distroprefs directory (o conf init prefs_dir). Second, configure a directory to hold you patches (o conf patches_dir). I choose patches under my .cpan directory, but it can be anything. Save your changes before you exit.
% cpan
% cpan[1]> o conf init prefs_dir
Directory where to store default options/environment/dialogs for
building modules that need some customization? [/Users/brian/.cpan/prefs]
% cpan[2]> o conf patches_dir /Users/brian/.cpan/patches
% cpan[3]> o conf commit
distroprefs have two parts. The first specifies what you want to happen. This can be a YAML, Storable, or Data::Dumper file. If YAML (which most people seem to use), then you need to install the YAML module first.
Here's a simple distroprefs file. It tells CPAN.pm how to match a distribution as you'd see it on CPAN (AUTHOR/FILE). In this example, it's action is patches, which is an array of patch files. Since you set up patches_dir, that's where it will look. The file name for the patch isn't special, and it can be compressed. I chose the distro name, my name as the person who patched it, then .patch.
---
match:
module: "Data::Match"
distribution: "^KSTEPHENS/Data-Match-0.06.tar.gz"
patches:
- Data-Match-0.06-BDFOY-01.patch
Here's your patch. Back up the original file, change the target file, then get the unified diff (or whatever your patch understands):
$ diff -u Match.pm.orig Match.pm
--- Match.pm.orig 2022-06-29 15:04:06.000000000 -0400
+++ Match.pm 2022-06-29 14:55:45.000000000 -0400
## -965,7 +965,7 ##
elsif ( $ref eq 'HASH' ) {
if ( ref($ind) eq 'ARRAY' ) {
# Not supported by DRef.
- $str .= $sep . '{' . join(',', #$ind->[0]) . '}';
+ $str .= $sep . '{' . join(',', #{$ind->[0]}) . '}';
} else {
$str .= $sep . $ind;
}
But you want this in your patches dir with the name that you specified, so redirect the output there:
$ diff -u Match.pm.orig Match.pm > /Users/brian/.cpan/patches/Data-Match-0.06-BDFOY-01.patch
If you want to get really fancy, you could put that patches directory in an environment variable in your profile so you don't have to remember it:
$ diff -u Match.pm.orig Match.pm > $CPAN_PATCHES_DIR/Data-Match-0.06-BDFOY-01.patch
Now when you try to install Data::Match with cpan, it knows that it's installing Data-Match-0.06, it matches that distro from a distroprefs file, and that distroprefs file tell CPAN.pm to perform an action. In this case, it needs to find the patch file and apply it. After the patch is applied, the tests pass and the installation succeeds:
% cpan Data::Match
Reading '/Users/brian/.cpan/Metadata'
Database was generated on Wed, 29 Jun 2022 05:56:00 GMT
Running install for module 'Data::Match'
______________________ D i s t r o P r e f s ______________________
Data-Match-0.06-BDFOY-01.yml[0]
Checksum for /Users/brian/.cpan/sources/authors/id/K/KS/KSTEPHENS/Data-Match-0.06.tar.gz ok
Applying 1 patch:
/Users/brian/.cpan/patches/Data-Match-0.06-BDFOY-01.patch
/usr/bin/patch -N --fuzz=3 -p0
patching file Match.pm
Configuring K/KS/KSTEPHENS/Data-Match-0.06.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Data::Match
Writing MYMETA.yml and MYMETA.json
KSTEPHENS/Data-Match-0.06.tar.gz
/usr/local/perls/perl-5.36.0/bin/perl Makefile.PL -- OK
Running make for K/KS/KSTEPHENS/Data-Match-0.06.tar.gz
cp Match.pm blib/lib/Data/Match.pm
cp lib/Sort/Topological.pm blib/lib/Sort/Topological.pm
Manifying 2 pod documents
KSTEPHENS/Data-Match-0.06.tar.gz
/usr/bin/make -- OK
Running make test for KSTEPHENS/Data-Match-0.06.tar.gz
PERL_DL_NONLAZY=1 "/usr/local/perls/perl-5.36.0/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
1..1
# Running under perl version 5.036000 for darwin
# Current time local: Wed Jun 29 15:54:13 2022
# Current time GMT: Wed Jun 29 19:54:13 2022
# Using Test.pm version 1.31
ok 1
PERL_DL_NONLAZY=1 "/usr/local/perls/perl-5.36.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/t1.t .. ok
t/t2.t .. ok
t/t3.t .. 1/15 splice() offset past end of array at /Users/brian/.cpan/build/Data-Match-0.06-15/blib/lib/Data/Match.pm line 1941.
t/t3.t .. ok
t/t4.t .. ok
All tests successful.
Files=4, Tests=182, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.18 cusr 0.04 csys = 0.26 CPU)
Result: PASS

Related

perl installation, cpan install true.pm fails

I am very much a perl newbie, I know very little about the system.
I am trying to install App/Lingua/BO/Wylie/Transliteration.pm which seems to be dependent on true.
I am getting an error on the install of true. This seems very surprising, so I am very open to something very fundamental and wrong with the perl installation. Running perl v5.30.2 on MacOS 11.3.1.
cpan error log:
force install true.pm
Running install for module 'true'
CHOCOLATE/true-v1.0.2.tar.gz
Has already been unwrapped into directory /Users/phil/.cpan/build/true-v1.0.2-0
CHOCOLATE/true-v1.0.2.tar.gz
Has already been prepared
Running make for C/CH/CHOCOLATE/true-v1.0.2.tar.gz
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- true.bs blib/arch/auto/true/true.bs 644
cc -c -I/Users/phil/perl5/lib/perl5/darwin-thread-multi-2level/B/Hooks/OP/Annotation/Install -I/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/B/Hooks/OP/Check/Install -g -pipe -fno-strict-aliasing -fstack-protector-strong -DPERL_USE_SAFE_PUTENV -O3 -Wall -W -DVERSION=\"v1.0.2\" -DXS_VERSION=\"v1.0.2\" -iwithsysroot "/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE" true.c
true.xs:8:10: fatal error: 'hook_op_check.h' file not found
#include "hook_op_check.h"
^~~~~~~~~~~~~~~~~
1 error generated.
make: *** [true.o] Error 1
CHOCOLATE/true-v1.0.2.tar.gz
/usr/bin/make -- NOT OK
Failed during this command:
CHOCOLATE/true-v1.0.2.tar.gz : make NO
true.xs:8:10: fatal error: 'hook_op_check.h' file not found
This looks like a bug in the system Perl installation that comes preinstalled on macOS. The module B::Hooks::OP::Check comes preinstalled in /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/B/Hooks/OP/ but the file /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/B/Hooks/OP/Check/Install/hook_op_check.h is missing for some reason. As a consequence, it is not possible to install the module true which depends on that file being there.
You can override the preinstalled version by running:
$ cpan -f B::Hooks::OP::Check
This will install the module into /Library/Perl/5.30/darwin-thread-multi-2level/B/Hooks/OP if you are using sudo with cpan, or into ~/perl5/lib/perl5/darwin-thread-multi-2level/B/Hooks/OP if you are using local::lib with cpan. This latter installation will be found before the preinstalled version due to the ordering of the perl #INC include path, so it will override the preinstalled version of the module.
This will enable you to install the module true, but after installing this the installation of App::Lingua::BO::Wylie::Transliteration still fails:
$ cpan App::Lingua::BO::Wylie::Transliteration
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/Users/hakonhaegland/.cpan/Metadata'
Database was generated on Sat, 01 Jan 2022 22:29:03 GMT
Running install for module 'App::Lingua::BO::Wylie::Transliteration'
Fetching with LWP:
http://www.cpan.org/authors/id/D/DB/DBR/App-Lingua-BO-Wylie-Transliteration-0.1.0.tar.gz
Fetching with LWP:
HASH(0x13444b3c8)authors/id/D/DB/DBR/CHECKSUMS
Fetching with LWP:
HASH(0x13444b3c8)authors/id/D/DB/DBR/CHECKSUMS.gz
Fetching with LWP:
http://www.cpan.org/authors/id/D/DB/DBR/CHECKSUMS
Checksum for /Users/hakonhaegland/.cpan/sources/authors/id/D/DB/DBR/App-Lingua-BO-Wylie-Transliteration-0.1.0.tar.gz ok
Configuring D/DB/DBR/App-Lingua-BO-Wylie-Transliteration-0.1.0.tar.gz with Build.PL
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'App-Lingua-BO-Wylie-Transliteration' version '0.1.0'
DBR/App-Lingua-BO-Wylie-Transliteration-0.1.0.tar.gz
/usr/bin/perl Build.PL -- OK
Running Build for D/DB/DBR/App-Lingua-BO-Wylie-Transliteration-0.1.0.tar.gz
Building App-Lingua-BO-Wylie-Transliteration
DBR/App-Lingua-BO-Wylie-Transliteration-0.1.0.tar.gz
./Build -- OK
Running Build test for DBR/App-Lingua-BO-Wylie-Transliteration-0.1.0.tar.gz
t/00-check-deps.t ........ ok
t/00-load.t .............. 1/1
# Failed test 'use App::Lingua::BO::Wylie::Transliteration;'
# at /Library/Perl/5.30/Test/UseAllModules.pm line 71.
# Tried to use 'App::Lingua::BO::Wylie::Transliteration'.
# Error: Couldn't find declarator 'method' at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/Devel/Declare/Context/Simple.pm line 47.
# Devel::Declare::Context::Simple::skip_declarator(Method::Signatures::Simple=HASH(0x12704f6d8)) called at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/Devel/Declare/MethodInstaller/Simple.pm line 62
# Devel::Declare::MethodInstaller::Simple::parser(Method::Signatures::Simple=HASH(0x12704f6d8), "method", 0, 1) called at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/Devel/Declare/MethodInstaller/Simple.pm line 25
# Devel::Declare::MethodInstaller::Simple::__ANON__("method", 0) called at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/Devel/Declare.pm line 277
# Devel::Declare::linestr_callback("const", "method", 0) called at lib/App/Lingua/BO/Wylie/Transliteration.pm line 37
# require App/Lingua/BO/Wylie/Transliteration.pm called at /Library/Perl/5.30/Test/UseAllModules.pm line 71
# Test::UseAllModules::BEGIN() called at lib/App/Lingua/BO/Wylie/Transliteration.pm line 37
# eval {...} called at lib/App/Lingua/BO/Wylie/Transliteration.pm line 37
# eval 'package Test::UseAllModules;
# BEGIN { ${^WARNING_BITS} = $args[-1] if defined $args[-1] }
# #line 71 /Library/Perl/5.30/Test/UseAllModules.pm
# use App::Lingua::BO::Wylie::Transliteration #{$args[0]};
# 1;
# ' called at /System/Library/Perl/5.30/Test/More.pm line 1034
# Test::More::_eval("package Test::UseAllModules;\x{a}BEGIN { \${^WARNING_BITS} = \$args"..., ARRAY(0x1268938e0), "UUUUUUUUUUUUUUUUUUU") called at /System/Library/Perl/5.30/Test/More.pm line 1009
# Test::More::use_ok("App::Lingua::BO::Wylie::Transliteration") called at /Library/Perl/5.30/Test/UseAllModules.pm line 71
# Test::UseAllModules::all_uses_ok() called at t/00-load.t line 4
# main::BEGIN() called at lib/App/Lingua/BO/Wylie/Transliteration.pm line 37
# eval {...} called at lib/App/Lingua/BO/Wylie/Transliteration.pm line 37
# Compilation failed in require at /Library/Perl/5.30/Test/UseAllModules.pm line 71.
# BEGIN failed--compilation aborted at /Library/Perl/5.30/Test/UseAllModules.pm line 71.
Bailout called. Further testing stopped: failed: App::Lingua::BO::Wylie::Transliteration
this is due to a recent change in Devel::Declare and a corresponding change in the parser in bleed described in these bug reports, report1 and report2.
A workaround is to install a an earlier version of perl together with an earlier version of Devel::Declare. You can do this using perlbrew. For example:
$ perlbrew install perl-5.26.3
$ cpanm Devel::Declare#0.006019
$ cpanm App::Lingua::BO::Wylie::Transliteration

perl module Class::HPLOO v0.23 install issue #2

Having the exact issue as described at: perl module Class::HPLOO v0.23 install issue, I have attempted to correct the defined(#array) problem by editing to just (#array) and trying to rebuild the module. However I continue to get the return of:
$ make clean
$ perl Makefile.PL
$ make
$ make test: *** No rule to
make target `clean:'. Stop. Manifying 2 pod documents
PERL_DL_NONLAZY=1 "/opt/local/bin/perl5.26" "-Iblib/lib" "-Iblib/arch"
test.pl
1..42
# Running under perl version 5.026002 for darwin
# Current time local: Sun Aug 26 06:48:26 2018
# Current time GMT: Sat Aug 25 22:48:26 2018
# Using Test.pm version 1.26 not ok 1
# Failed test 1 in test.pl at line 9
# test.pl line 9 is: ok(!$#) ; Can't locate object method "new" via package "Foo" at test.pl line 11. make: *** [test_dynamic] Error 2
There are three issues with Class::HPLOO (which as I noted before, hasn't been updated since 2005) that make it fail with modern perls.
As discovered in the previous post,
the obsolete construct defined (#array) is used once in lib/Class/HPLOO.pm' and three times inlib/Class/HPLOO/Base.pm`. This construction has been prohibited since v5.22
The current directory (.) is no longer in #INC (as of v5.24, I think). So the lines in test.pl like
require "test/classtest.pm"
either all need to be rewritten as
require "./test/classtest.pm"
or an easier fix is to put
use lib '.';
at the top of the script.
There is a regular expression in lib/Class/HPLOO.pm, line 1077, with an "unescaped left brace"
$sub =~ s/(\S)( {) (\S)/$1$2\n$FIRST_SUB_IDENT $3/gs ;
{ is a regex metacharacter, and since v5.22 it has been illegal to use it in a context where it is not indicating a quantity. The fix, as the error message suggests, is to escape it.
$sub =~ s/(\S)( \{) (\S)/$1$2\n$FIRST_SUB_IDENT $3/gs ;
Make these three changes to the code you download from CPAN and the module should build on modern Perls. If you're feeling helpful, you can submit a bug report (linking to this post, if you want) or even a patch with an email to bug-Class-HPLOO#rt.cpan.org
come across this issue today, so I fixed it following the answer above. if anyone want to save some time.
I create a repo with the changes. https://github.com/swuecho/Class_HPLOO.git

Why does "Can not locate Debconf / Log.pm in #INC" issue? I just modified /usr/bin/perl into the perl that I installed

The system is Ubuntu. There is a perl in /usr/bin/, and is version is 5.18.2.
In this state, I tried to install many software by "sudo apt-get install **" and it was OK.
But a few days before, I installed a new perl in an other
directory(/share/Software/perl-5.26.0/bin/perl). And I remove the original perl then link the new perl to /use/bin/. The commands are:
sudo mv /usr/bin/perl /usr/bin/old/; (the old/ directory was make before)
sudo ln -s /share/Software/perl-5.26.0/bin/perl /usr/bin/perl
After that, I got the error informations when I install system software by apt-get. The error likes below:
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
debconf: Perl may be unconfigured (Can't locate Debconf/Log.pm in #INC (you may need to install the Debconf::Log module) (#INC contains: /share/Software/perl-5.26.0/lib/site_perl/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/site_perl/5.26.0 /share/Software/perl-5.26.0/lib/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/5.26.0) at (eval 1) line 4.
BEGIN failed--compilation aborted at (eval 1) line 4.
) -- aborting
Setting up doc-base (0.10.5) ...
Can't locate Debian/DocBase/Common.pm in #INC (you may need to install the Debian::DocBase::Common module) (#INC contains: /share/Software/perl-5.26.0/lib/site_perl/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/site_perl/5.26.0 /share/Software/perl-5.26.0/lib/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/5.26.0) at /usr/sbin/install-docs line 8.
BEGIN failed--compilation aborted at /usr/sbin/install-docs line 8.
Some software can be installed successfully, but some can not be.
If I put perl back to the previous, it is normal again. (That must be!)
Module "Debconf::Log" is located at /share/Software/perl-5.26.0/lib/perl5, but I can not find Debian/DocBase/Common.pm.
Path of /share/Software/perl-5.26.0/lib/perl5 is inside #INC of perl. Why it can not find it?
I even think that it is the problem when perl installed. I get below error when perl installed: ("make test")
Useless use of single ref constructor in void context at op/gv.t line 1191.
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
ExtTest.c: In function ‘XS_ExtTest_constant’:
../../../../embed.h:691:40: warning: ‘pv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c)
^
ExtTest.xs:420:14: note: ‘pv’ was declared here
const char *pv;
^
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
../../../../embed.h:691:40: warning: ‘iv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c)
^
ExtTest.xs:418:6: note: ‘iv’ was declared here
IV iv;
^
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
ExtTest.c: In function ‘XS_ExtTest_constant’:
../../../../embed.h:691:40: warning: ‘pv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c)
^
ExtTest.xs:194:14: note: ‘pv’ was declared here
const char *pv;
^
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
ExtTest.c: In function ‘XS_ExtTest_constant’:
../../../../embed.h:675:42: warning: ‘iv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setiv_mg(a,b) Perl_sv_setiv_mg(aTHX_ a,b)
^
ExtTest.xs:166:6: note: ‘iv’ was declared here
IV iv;
^
# Failed test 'cp updated mtime'
# at t/cp.t line 26.
# '38'
# <=
# '1'
# Looks like you failed 1 test of 1.
Request to remove file /share/Software/perl-5.26.0-src/cpan/File-Temp/suffixOEXZVr.dat could not be completed since it is not there!
at t/mktemp.t line 75.
# parser guessed wrong encoding expected 'CP1252' got 'UTF-8'
# Failed test 'File 1 atime set correctly'
# at t/utime.t line 113.
# '37.684463262558'
# <
# '0.1'
# Failed test 'File 1 mtime set correctly'
# at t/utime.t line 114.
# '37.684463262558'
# <
# '0.1'
# Failed test 'File 2 atime set correctly'
# at t/utime.t line 118.
# '37.684463262558'
# <
# '0.1'
# Failed test 'File 2 mtime set correctly'
# at t/utime.t line 119.
# '37.684463262558'
# <
# '0.1'
# Looks like you failed 4 tests of 18.
Can't open copy1-87150: Permission denied at ../lib/File/Copy.t line 326.
# Looks like your test exited with 13 just after 366.
Failed 3 tests out of 2449, 99.88% okay.
### Since not all tests were successful, you may want to run some of
### them individually and examine any diagnostic messages they produce.
### See the INSTALL document's section on "make test".
### You have a good chance to get more information by running
### ./perl harness
### in the 't' directory since most (>=80%) of the tests succeeded.
### You may have to set your dynamic library search path,
### LD_LIBRARY_PATH, to point to the build directory:
### setenv LD_LIBRARY_PATH `pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd t; ./perl harness
### export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### for csh-style shells, like tcsh; or for traditional/modern
### Bourne-style shells, like bash, ksh, and zsh, respectively.
make: *** [test] Error 1
Each Perl is compiled with a few #INC directories where it will search for modules. The error message explains which directories are searched:
#INC contains:
/share/Software/perl-5.26.0/lib/site_perl/5.26.0/x86_64-linux
/share/Software/perl-5.26.0/lib/site_perl/5.26.0
/share/Software/perl-5.26.0/lib/5.26.0/x86_64-linux
/share/Software/perl-5.26.0/lib/5.26.0
This does not include the directories where APT has installed modules for Perl, e.g. under /usr/lib.
However, adding those directories will not help. Some modules are compiled for a specific Perl versions. You cannot upgrade Perl in-place, but would have to reinstall all modules. Since APT contains pre-built modules you cannot use modules installed via APT with a custom Perl.
Therefore: leave the system Perl because Ubuntu depends on its proper functioning. It is safe to install another Perl alongside, e.g. via perlbrew. It is safe to add a custom Perl to your PATH, e.g. via perlbrew switch. This will also fix a couple of additional environment variables that are required for a second Perl to work.

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;
}

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

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.