Perl can't locate Tie/File/AsHash.pm - perl

I have a code
use Tie::File::AsHash;
tie %sets, 'Tie::File::AsHash', '.\\main\\old_names.txt', split => '\+' or die "Problem trying to %hash: $!";
and I get the error:
Can't locate Tie/File/AsHash.pm in #INC <#INC contains: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .> at C:\Users\user\Desktop\test.pl line 97 (which is the second line I posted)
BEGIN failed--compilation aborted at line 97.

That usually indicates that the module isn't installed. One normally installs a module as follows:
cpan Tie::File::AsHash

Related

Module installed with cpan isn't showing up

I'm trying to install Array::Iterator and Text::ParseWords using cpan. I'm on OSX with cpan v1.61 and perl v5.18.2.
When I start up cpan, after the initial configuration, I type install "Array::Iterator" and it seems to install correctly. But when I try to run my perl script with use Array::Iterator, I get:
Can't locate Array/Iterator.pm in #INC (you may need to install the Array::Iterator module) (#INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at ./parse.pl line 7.
at ./parse.pl line 7.
main::BEGIN() called at ./parse.pl line 7
eval {...} called at ./parse.pl line 7
BEGIN failed--compilation aborted at ./parse.pl line 7.
at ./parse.pl line 7.
Line 7 is:
use Array::Iterator;
Add the complete PATH where your Array::Iterator pm file is located
Use the below code in start of the script after shebang line may be the path is not loaded
BEGIN { push( #INC, 'PATH' ) }

getting error while using pdftk tool

for performing the pdf modifications install the cpan module PDF::Tk [Perl integration for the pdf toolkit (pdftk)], but while using the functionality of pdftk getting the below set of error, Can anyone please help me in resolving this.
code samples used:
script name: test.pl -- used to reverse the pdf contain
1)use PDF::Tk;
pdftk inputPDF.pdf cat end-1 output outPDF.pdf
==> Can't locate IO/All.pm in #INC (#INC contains: /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib64/perl5/vendor_perl/5.8.3/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/site_perl/5.8.5/PDF/Tk.pm line 2.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.5/PDF/Tk.pm line 2.
Compilation failed in require at testPDF.pl line 1.
BEGIN failed--compilation aborted at testPDF.pl line 1.
2) use PDFTk;
pdftk inputPDF.pdf cat end-1 output outPDF.pdf
==>Can't locate PDFTk.pm in #INC (#INC contains: /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib64/perl5/vendor_perl/5.8.3/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl .) at testPDF.pl line 1.
BEGIN failed--compilation aborted at testPDF.pl line 1.
I don't really understand your second example. You're talking about PDF::Tk, so I don't know why you're trying to use a module called PDFTk. I think we can safely ignore that.
Your first example looks like it's getting further. It has found PDF::Tk and is trying to load it. But something is loading IO::All which is apparently missing from your system.
So the solution is to install IO::All. But it makes me wonder how you installed PDF::Tk. Any sane module installation method will also pull in any required modules (and IO::All is clearly listed as a required module for PDF::Tk).

How to use XPath.pm in perl script?

I've followed following link for the issues i faced.
http://stackoverflow.com/questions/11192967/using-xpath-with-perl
Really I don't know how to use. Please guide me in proper way.
Issue :
Can't locate XML/XPathEngine.pm in #INC (#INC contains: /perl/site/lib C:/Dwimpe
rl/perl/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .) at C:/Dwimp
erl/perl/site/lib/XPath.pm line 103.
BEGIN failed--compilation aborted at C:/Dwimperl/perl/site/lib/XPath.pm line 103
.
Compilation failed in require at Multi_instance_run1.pl line 9.
BEGIN failed--compilation aborted at Multi_instance_run1.pl line 9.
The following steps i followed for this
- In perl script, used like require XPath;
- After that executed command cpan XML::XPath .
-I've copied following files in the path C:\Dwimperl\perl\site\lib
XPath.pm
XPathEngine.pm
what did I miss ? where did I made mistake ? How to use XPath.pm ? How to include it in perl script ?
Try to put XPathEngine to C:\Dwimperl\perl\site\lib\XML folder

Perl 5.14.2-7u21deb - Error with ConfigLocal.pm (Number found where operator expected)

i've been expiriencing a strange issue and can't figure out the cause.
I'm trying to check an ESXi Host with the Nagiosplugin check_esx3
Whenever i call the script, i get a proper return, but right before i get the Error as follows:
Number found where operator expected at /usr/local/lib/perl/5.14.2/Encode/ConfigLocal.pm line 13, near "$_ModLines_
1"
(Missing semicolon on previous line?)
Since any other interaction with Perl runs into same scenario, it migt be something at the very basic. Unluckily im not tat familiar with Perl.
Trying to call "enc2xs -C" i get :
Number found where operator expected at /usr/local/lib/perl/5.14.2/Encode/ConfigLocal.pm line 13, near "$_ModLines_
1"
(Missing semicolon on previous line?)
require Encode;
require Encode;
require Encode::Symbol;
require Encode::Byte;
require Encode::Config;
require Encode::Encoder;
require Encode::EBCDIC;
require Encode::Alias;
require Encode::ConfigLocal;
Can't require Encode::ConfigLocal: Attempt to reload Encode/ConfigLocal.pm aborted.
Compilation failed in require at (eval 16) line 1.
Content of /usr/local/lib/perl/5.14.2/Encode/ConfigLocal.pm :
#
# Local demand-load module list
#
# You should not edit this file by hand! use "enc2xs -C"
#
package Encode::ConfigLocal;
our $VERSION = $_LocalVer_;
use strict;
$_ModLines_
1;
Perlversion info:
Built under linux
Compiled at Sep 30 2013 03:45:34
%ENV:
PERL_LWP_SSL_VERIFY_HOSTNAME="0"
#INC:
/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
.
Just remove /usr/local/lib/perl/5.14.2/Encode/ConfigLocal.pm. It's optional (see the source code of Encode.pm, the require Encode::ConfigLocal is wrapped in an eval block) and not part of normal perl installations. enc2xs -C would create a new Encode::ConfigLocal, but apparently there's a bug which creates an invalid file. Anyway, unless you really think you need it, just remove it.
As said in the error message, a semicolon is missing on previous line:
package Encode::ConfigLocal;
our $VERSION = $_LocalVer_;
use strict;
$_ModLines_;
# here __^
1;

Why do I get "version (5.12.2) doesn't match executable version" with Perl's PAR?

When I run the following to create an executable out of my Perl script:
pp -o process_target_mode_data Process_Target_Mode_Data.pl
I get the following error output:
Perl lib version (5.12.2) doesn't match executable version (v5.12.0) at /home/Neil/ActivePerl-5.12/lib/Config.pm line 50.
Compilation failed in require at /home/Neil/ActivePerl-5.12/lib/Errno.pm line 8.
BEGIN failed--compilation aborted at /home/Neil/ActivePerl-5.12/lib/Errno.pm line 8.
Compilation failed in require at /home/Neil/ActivePerl-5.12/lib/File/Temp.pm line 148.
BEGIN failed--compilation aborted at /home/Neil/ActivePerl-5.12/lib/File/Temp.pm line 148.
Compilation failed in require at /home/Neil/ActivePerl-5.12/lib/Archive/Zip.pm line 14.
BEGIN failed--compilation aborted at /home/Neil/ActivePerl-5.12/lib/Archive/Zip.pm line 14.
Compilation failed in require at -e line 459.
/home/Neil/ActivePerl-5.12/site/bin/pp: Failed to extract a parl from 'PAR::StrippedPARL::Static' to file 'parleNrP2Xi' at /home/Neil/ActivePerl-5.12/site/lib/PAR/Packer.pm line 1172, <DATA> line 1.
Could someone explain to me what is going on and how I can resolve this problem?
Info brian d foy requested:
[bash-3.2][Neil#willy]$ which pp
/home/Neil/ActivePerl-5.12/site/bin/pp
[bash-3.2][Neil#willy]$ /home/Neil/ActivePerl-5.12/site/bin/pp -o process_target_mode_data Process_Target_Mode_Data.pl
Perl lib version (5.12.2) doesn't match executable version (v5.12.0) at /home/Neil/ActivePerl-5.12/lib/Config.pm line 50.
Compilation failed in require at /home/Neil/ActivePerl-5.12/lib/Errno.pm line 8.
BEGIN failed--compilation aborted at /home/Neil/ActivePerl-5.12/lib/Errno.pm line 8.
Compilation failed in require at /home/Neil/ActivePerl-5.12/lib/File/Temp.pm line 148.
BEGIN failed--compilation aborted at /home/Neil/ActivePerl-5.12/lib/File/Temp.pm line 148.
Compilation failed in require at /home/Neil/ActivePerl-5.12/lib/Archive/Zip.pm line 14.
BEGIN failed--compilation aborted at /home/Neil/ActivePerl-5.12/lib/Archive/Zip.pm line 14.
Compilation failed in require at -e line 459.
/home/Neil/ActivePerl-5.12/site/bin/pp: Failed to extract a parl from 'PAR::StrippedPARL::Static' to file 'parludZfldz' at /home/Neil/ActivePerl-5.12/site/lib/PAR/Packer.pm line 1172, line 1.
[bash-3.2][Neil#willy]$
[bash-3.2][Neil#willy]$ /home/Neil/ActivePerl-5.12/bin/cpan -l | grep PAR
PAR 1.002
PAR::Dist 0.47
PAR::Heavy 0.12
PAR::Filter 0.03
PAR::SetupTemp 1.002
PAR::SetupProgname 1.002
PAR::Packer 1.006
PAR::StrippedPARL::Dynamic 0.958
PAR::StrippedPARL::Static 0.958
PAR::StrippedPARL::Base 0.975
PAR::Filter::Bytecode undef
PAR::Filter::Bleach undef
PAR::Filter::Obfuscate undef
PAR::Filter::PatchContent undef
PAR::Filter::PodStrip undef
App::Packer::PAR 0.91
Perl lib version (5.12.2) doesn't match executable version (v5.12.0)
Some parts of your Perl installation are at a different version than others. More specifically, if you look at /home/Neil/ActivePerl-5.12/lib/Config.pm line 50, you will see that there is an explicit comparison of the version of Perl being executed (which is 5.12.0) to the version of the Config.pm library being used (5.12.2).
If you perform a new installation of ActivePerl 5.12.2 (to bring all components up to the same version), this error should go away.
I had same issue. I installed PAR::Packer from Activestate Perl Package Manager (PPM). As mentioned above in one of the replies, there is version mismatch between the perl and pp binaries. Here's how I fixed it:
Uninstall PAR-Packer from PPM.
Open DOS command line.
Run cpan install PAR::Packer
This will download, compile, and install the package from CPAN. MinGW compiler toolchain will be downloaded as well, if needed. The whole process may take a while on slower cpus.
Find the location of that pp, then figure out its version. I bet it's left over from an earlier installation. Ensure that you have PAR for your new version of Perl.
You can also try specifying the location of the particular pp you want to use so you know exactly what one you are using:
$ /full/path/to/5.12.2/pp ...
Go to the perl/lib/Config.pm and changed the condition in the lines:
die "$0: Perl lib version (5.32.0) doesn't match executable '$^X' version ($])" unless $^V;
to
die "$1: Perl lib version (5.32.1) doesn't match executable '$^X' version ($])" unless $^V;
and the next line
$^V eq 5.32.0 or die sprintf "%s: Perl lib version (5.32.0) doesn't match executable '$^X' version (%vd)", $0, $^V;
to
$^V eq 5.32.1 or die sprintf "%s: Perl lib version (5.32.1) doesn't match executable '$^X' version (%vd)", $0, $^V;
this worked for me, at least it won't complain... yes, i know, PERL and Python are f***d up.