How to use XPath.pm in perl script? - perl

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

Related

Getting error while executing makeinfo on cygwin

While executing makeinfo on cygwin I am getting the following errors. I am using the perl version 5.32.1
23:16 Harshal:~> makeinfo
Can't locate if.pm in #INC (you may need to install the if module) (#INC contains: /usr/lib/texinfo /usr/share/texinfo/lib/Text-Unidecode/lib /usr/share/texinfo/lib/Unicode-EastAsianWidth/lib /usr/share/texinfo/lib/libintl-perl/lib /usr/share/texinfo /usr/share/texinfo /usr/local/lib/perl5/site_perl/5.32/x86_64-cygwin-threads /usr/local/share/perl5/site_perl/5.32 /usr/lib/perl5/vendor_perl/5.32/x86_64-cygwin-threads /usr/share/perl5/vendor_perl/5.32 /usr/lib/perl5/5.32/x86_64-cygwin-threads /usr/share/perl5/5.32) at /usr/share/texinfo/Texinfo/Structuring.pm line 27.
BEGIN failed--compilation aborted at /usr/share/texinfo/Texinfo/Structuring.pm line 27.
Compilation failed in require at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 32.
BEGIN failed--compilation aborted at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 32.
Compilation failed in require at /usr/bin/makeinfo line 99.
BEGIN failed--compilation aborted at /usr/bin/makeinfo line 99.
If someone can provide some pointer on how to resolve this issue would be helpful
I tried updating the perl version. I tried commetting out the code on line num 27 in structuring.pm didn;t workout. I am not from software background but i need the above thing for some RISCV based toolchain update.
Any help woudl be really appreciated .
Something's wrong with your system. This is a file included in the perl-5.32.1-2 package. It should be found at
/usr/share/perl5/5.32/if.pm
Try reinstalling the perl package. If the file isn't missing, something's wrong with the permissions.

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).

Perl module broke my windows xampp installation

PROBLEM: In the process of trying to install gitstat on a Windows7 machine I broke my xampp Apache installation. Now I can't get gitstat or apache to work.
APACHE ERROR:
[error] Can't load Perl file: C:/xampp/apache/conf/extra/startup.pl for server localhost:80, exiting...`
Other people have reported this issue being caused by the PERL5LIB environment variable, but that variable does not exist on my machine.
WHAT I DID / GITSTAT ERROR:
I needed the SOAP::Lite module installed so I followed the windows guide here: http://soaplite.com/install.html
As far as I could tell I installed the module successfully, console output below
cpan[1]> install SOAP::Lite
CPAN: Storable loaded ok (v2.21)
Going to read '\xampp\perl\bin\.cpan\Metadata'
Database was generated on Wed, 27 Jun 2012 02:47:03 GMT
SOAP::Lite is up to date (0.714).
I saw a SOAP directory in perl/site/lib which (to me) means that the module should be available. When I look in my perllocal.pod file SOAP:Lite is in there.
Part of the gitstat installation instructions say to copy the Lite.pm file from perl/site/lib/SOAP into gitstat\gstat_pl\lib
However, when I try to perform step nine of gitstat installation (perl gitstat.pl HEAD) I get the following:
C:\xampp\htdocs\gitstat\gstat_pl>perl gitstat.pl HEAD
Supported versions:
BEGIN failed--compilation aborted at C:/xampp/perl/site/lib/SOAP/Lite.pm line 34
86.
Compilation failed in require at C:/xampp/perl/site/lib/SOAP/Constants.pm line 1
3.
BEGIN failed--compilation aborted at C:/xampp/perl/site/lib/SOAP/Constants.pm li
ne 13.
Compilation failed in require at lib/Lite.pm line 3444.
BEGIN failed--compilation aborted at lib/Lite.pm line 3444.
Compilation failed in require at gitstat.pl line 30.
If I don't copy the file from perl/site/lib/SOAP then I get
C:\xampp\htdocs\gitstat\gstat_pl>perl gitstat.pl HEAD
Can't locate lib/Lite.pm in #INC (#INC contains: C:/xampp/perl/lib C:/xampp/perl
/site/lib .) at gitstat.pl line 30.
I don't understand why CPAN didn't install the Lite.pm module in the #INC path or why the compilation might fail when the module is available, or most importantly why my Apache install is broken. Also I'm very new to Perl and CPAN and my understanding of Apache is primitive so simpler explanations would be greatly appreciated.

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

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

Error when trying to use XML::Parser under modperl2 - Could not load module

I've run into a problem when using XML::Parser under our modperl setup in production (on AIX 5.3). It works fine in development but fails on production with the following error:
[Tue Apr 03 08:44:03 2012] [error] Can't load '/wload/es1p/app/perl/lib/site_perl/5.10.1/aix/auto/XML/Parser/Expat/Expat.so' for mo
ule XML::Parser::Expat: Could not load module /wload/es1p/app/perl/lib/site_perl/5.10.1/aix/auto/XML/Parser/Expat/Expat.so.\n\tDepe
dent module /wload/es1p/app/usr/local/apache2/lib/libexpat.a(libexpat.so.1) could not be loaded.\n\tMember libexpat.so.1 is not fou
d in archive \nCould not load module /wload/es1p/app/perl/lib/site_perl/5.10.1/aix/auto/XML/Parser/Expat/Expat.so.\n\tDependent mod
le /wload/es1p/app/perl/lib/site_perl/5.10.1/aix/auto/XML/Parser/Expat/Expat.so could not be loaded. at /wload/es1p/app/perl/lib/5.
0.1/aix/DynaLoader.pm line 200.\n at /wload/es1p/app/perl/lib/site_perl/5.10.1/aix/XML/Parser.pm line 18\nCompilation failed in req
ire at /wload/es1p/app/perl/lib/site_perl/5.10.1/aix/XML/Parser.pm line 18.\nBEGIN failed--compilation aborted at /wload/es1p/app/p
rl/lib/site_perl/5.10.1/aix/XML/Parser.pm line 22.\nCompilation failed in require at /wload/es1p/app/perl/lib/site_perl/5.10.1/XML/
Path/XMLParser.pm line 7.\nBEGIN failed--compilation aborted at /wload/es1p/app/perl/lib/site_perl/5.10.1/XML/XPath/XMLParser.pm li
e 7.\nCompilation failed in require at /wload/es1p/app/perl/lib/site_perl/5.10.1/XML/XPath.pm line 13.\nBEGIN failed--compilation a
orted at /wload/es1p/app/perl/lib/site_perl/5.10.1/XML/XPath.pm line 13.\nCompilation failed in require at /wload/es1p/app/perl/lib
site_perl/5.10.1/Net/SAML2/IdP.pm line 23.\nBEGIN failed--compilation aborted at /wload/es1p/app/perl/lib/site_perl/5.10.1/Net/SAML
/IdP.pm line 23.\nCompilation failed in require at /wload/es1p/app/perl/lib/site_perl/5.10.1/Net/SAML2.pm line 69.\nBEGIN failed--c
mpilation aborted at /wload/es1p/app/perl/lib/site_perl/5.10.1/Net/SAML2.pm line 69.\nCompilation failed in require at /wload/es1p/
pp/usr/local/apache2/perl-bin/sso.pl line 4.\nBEGIN failed--compilation aborted at /wload/es1p/app/usr/local/apache2/perl-bin/sso.pl
The expat/expat-devel libraries were installed into /opt/freeware/lib using a package (the same one on dev and live) and both show the same output from ldd Expat.so:
Expat.so needs:
/usr/lib/libc.a(shr.o)
/opt/freeware/lib/libexpat.a(libexpat.so.1)
/unix
/usr/lib/libcrypt.a(shr.o)
I've tried setting up LIBPATH both in our dotfiles and in our mod_env configuration but with no luck. I'm not expecting someone to know the exact answer but I've run out of ideas as to what I can try so I'm hoping for some suggestions to try out.
EDIT: I should also point out that the same script using XML::Parser works perfectly as a normal cgi-bin script on our live server.
One thought: Maybe there are two different XML::Parser installed on your prod server. Your CGI pick one and your script pick the another?
Print out the #INC from script (on prod and dev) and from your working CGI and compare the result.
regards,