Perl Execution error - perl

I just upgraded my Active Perl Version. If I call any Perl script through the windows command prompt or through UltraEdit (Text Editor) I am able to execute it perfectly but if I call it through cygwin terminal I am getting this error -
Can't locate Date/Pcalc.pm in #INC (#INC contains:
/usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int
/usr/lib/perl5/site_perl/5.14
/usr/lib/perl5/vendor_perl/5.14/i686-cygwin-threads-64int
/usr/lib/perl5/vendor_perl/5.14
/usr/lib/perl5/5.14/i686-cygwin-threads-64int /usr/lib/perl5/5.14
/usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_perl/5.10
/usr/lib/perl5/site_perl/5.8 .) at Test.pl line 3. BEGIN
failed--compilation aborted at Test.pl line 3.
Even though the PCalc module is installed, it is looking in the wrong path for the PCalc.pm file. Any thoughts on how to resolve this and what it means ?
Any help is much appreciated ! Thanks.

Are you referencing the correct Perl ? i.e. are you picking up the Cygwin Perl installation as opposed to the ActiveState version ?
If you're referencing the correct Perl, then you should amend your PERL5LIB environment variable to reflect your local installation of Date/Pcalc.pm. See here for more details.

Related

Perl Compilation Error: "Can't locate local/lib.pm"

As a Perl rookie, I have made a rookie mistake.
I was working on a project that required an HTML parser so I thought I'd install Perl's HTML::TreeBuilder::XPath module, so I dove into cpan and perlbrew without a full understanding of how they work. I created a local library, but would like to return everything back to default. However, I get this error every time I open a terminal window (twice, for some reason):
Can't locate local/lib.pm in #INC (#INC contains:
/Users/James/perl5/lib/perl5
/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.4/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.4
/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 .).
BEGIN failed--compilation aborted.
I've seen the similar StackOverflow question here but I do not have apt-get installed.
How can I reset my machine so that this error no longer appears and it uses the default library?
The local::lib installation instructions tell you to add a line to your .bashrc or .bash_profile. From your error, it looks like the line
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
is still present. Look for it and remove it.
For me this meant I had an earlier aborted run of cpan's installation.
fix: remove ~/.cpan and ~/perl5 dirs, and remove anything about them from .bashrc, and do it again...

Bugzilla 5.0 install on OpenShift - Can't locate parent.pm in #INC

Attempting to install Bugzilla on an OpenShift small gear. Using SSH to wget 5.0 tarball, untar-ing and running the checksetup.pl --check-modules script gives me this error:
Can't locate parent.pm in #INC (INC contains: . lib /var/openshift/[app-id]/app-root
/runtime/repo/libs /var/lib/openshift/[app-id]/perl/perl5lib/lib/perl5 /usr/local/lib64
/perl5 /usr/local/share/perl5 /usr/lib/lib64/perl5/vendor-perl /usr/share/perl5/vendor-perl
/usr/lib64/perl5 usr/share/perl5) at Bugzilla/Constants.pm line 14.
BEGIN failed--compilation aborted at Bugzilla/Constants.pm line 14.
Compilation failed in require at ./checksetup.pl line 27.
BEGIN failed--compilation aborted at ./checksetup.pl line 27.
Line 14 of Bugzilla/Constants.pm: `use parent qw(Exporter);`
Line 27 of ./checksetup.pl: `use Bugzilla::Constants;`
[app-id] in the paths is just a random string of hex digits used to identify an OpenShift application.
All help would be greatly appreciated. Thanks in advance!
That means either parent is not installed in your system or it's not a part of #INC.
Try perldoc -l parent to see if it's installed or not.
If it's installed then update PERL5LIB enviroment variable to add path to directory where module is installed.
If it's not installed then run cpan parent to install.
Also see:
How do I 'use' a Perl module in a directory not in #INC?
How to change #INC to find Perl modules in non-standard locations
Apparantly OpenShift has a cpan.txt file in the .openshift folder. Adding parent to that folder installed the required module.
#please install above packages:
[root#rsync ~]# yum install perl-parent -y

Installing cURL modules for Perl on Windows

I have ActivePerl 5.14.2 on my Windows machine. I have been trying to install the LWP cURL module. I have already installed the libcurl-dev library and GCC on my machine.
I also understand that LWP cURL has a dependency on the WWW-Curl-Easy module. So I installed that too. I installed all these through the command lines using the steps given in the Readme files. I ran the perl makefile.pl command followed by a make and a make install. No errors were given out during the installation.
I am trying to execute this sample code to test my LWP cURL installation:
use LWP::Curl;
use strict;
use warnings;
my $lwpcurl = LWP::Curl->new();
my $content = $lwpcurl->get('http://search.cpan.org','http://www.cpan.org');
I am receiving the below error:
Can't locate loadable object for module WWW::Curl in #INC (#INC
contains: C:/Perl64/site/lib C:/Perl64/lib .) at
C:/Perl64/site/lib/WWW/Curl.pm line 11. BEGIN failed--compilation
aborted at C:/Perl64/site/lib/WWW/Curl.pm line 11. Compilation failed
in require at C:/Perl64/site/lib/WWW/Curl/Easy.pm line 9. Compilation
failed in require at C:/Perl64/site/lib/LWP/Curl.pm line 5. BEGIN
failed--compilation aborted at C:/Perl64/site/lib/LWP/Curl.pm line 5.
Compilation failed in require at D:\Varsha\Curl.pl line 1. BEGIN
failed--compilation aborted at D:\Varsha\Curl.pl line 1.
Where am I going wrong?
This is probably not the direction you want to go, but I'd advise you to consider upgrading your perl and changing distributions:
Install Strawberry Perl - 5.18.2.2 is the currently recommended version.
Install cpanm: perl -MCPAN -e "install App::cpanminus"
Install LWP::Curl: cpanm LWP::Curl
I won't bother trying convince you of the change, but Strawberry Perl and cpanm in combination make installing modules a lot easier than having to dealing with the proprietary ppm's of ActivePerl in my opinion.
Just something to consider if you ever get tired of the occasional headaches.
The error means that WWW::Curl is either not installed or its path is not searchable (it's not in #INC). So the solutions are
Make sure that the module is installed.
Add the path where the module is installed to the #INC. Since you are on Windows, you can use set PERL5LIB = c:\path\to\dir
For a permanent solution follow the below:
Right-click My Computer and click Properties.
In the System Properties window, click on the Advanced tab.
In the Advanced section, click the Environment Variables button.
In the Environment Variables window in the "User variables for Foo Bar" section click on New and type in the following:
Variable name: PERL5LIB
Variable value: c:\path\to\dir
Then click OK 3 times. Windows that you open after this will already know about the new variable. Type this in the command window, to see the newly set value:
echo %PERL5LIB%
This will add the private /home/foobar/code directory (or c:\path\to\dir directory) to the beginning of #INC for every script that is executed in the same environment.
Also see: Installing perl dependency automatically in perl

Expect module not working in perl

I have installed expect module in perl at location C:\strawberry\perl\lib.
As a pre-requisite i have installed IO-Tty module first at same location were perl is installed.
Now if i am doing
use Expect;
It is throwing error
Can't locate IO/Pty.pm in #INC (#INC contains: C:/strawberry/perl/site/lib C:/st
rawberry/perl/vendor/lib C:/strawberry/perl/lib .) at C:/strawberry/perl/lib/Exp
ect.pm line 22.
BEGIN failed--compilation aborted at C:/strawberry/perl/lib/Expect.pm line 22.
Compilation failed in require at croak.txt line 1.
BEGIN failed--compilation aborted at croak.txt line 1.
Possible reasons are
Perl is looking for IO::Pty and IO::Tty module which are called from Expect.pm. But When i have installed IO::Tty module, it is having 2 pm files with names Pty.pm and Tty.pm
package Expect;
use IO::Pty 0.97; # We need make_slave_controlling_terminal()
use IO::Tty;
But perl is looking for IO::Tty module.
Is this causing the issue. If yes then how can i move forward
Expect does not work under Windows.
At least this is my impression when looking at CPAN Resters results. This table here:
http://matrix.cpantesters.org/?dist=Expect;maxver=1
shows that there was never a PASS for Expect under Windows.
Also, the Expect documentation talks about the module not working with ActivePerl and recommends to use cygwin instead:
https://metacpan.org/module/RGIERSIG/Expect-1.21/Expect.pod#Can-I-use-this-module-with-ActivePerl-on-Windows.
I assume that Expect does not work with StrawberryPerl, too.
Did you installed these modules using cpan? - I would highly recommend to install modules only via cpan, so you'll get all the dependencies needed.
If you've done so, try to reinstall it and watch out for any errors.
I tested the install via cpan and it needs to compile the IO::Tty package, so maybe you need to set-up an build environment for any perl modules you would like to install.
If you just copied some precompiled files verify that the files you're missing really exist and download the package again.
Edit:
What I missed - The full path for your Pty.pm and Tty.pm should be something like "C:/strawberry/perl/lib/IO/Tty.pm"

Why does Perl say that it can't find my module?

I wanted to play with XML::Rabbit, however I've got a problem even with the simplest code. I managed to strip this into one line.
In a simple file, I use
use Class::Load;
and then:
perl test_optlist.pl
Can't locate Data/OptList.pm in #INC (you may need to install the Data::OptList module) (#INC contains: [CUT]) at /home/szymon/perl5/lib/perl5/Class/Load.pm line 8.
BEGIN failed--compilation aborted at /home/szymon/perl5/lib/perl5/Class/Load.pm line 8.
Compilation failed in require at test_optlist.pl line 2.
BEGIN failed--compilation aborted at test_optlist.pl line 2.
so let's install it:
$ cpanm Data::OptList
Data::OptList is up to date. (0.107)
Perl version:
This is perl 5, version 17, subversion 8 (v5.17.8) built for x86_64-linux
Where is the problem?
You're surely using another perl's cpanm. Do
perlbrew install-cpanm
to install a version of cpanm under perlbrew's control, make sure this new cpanm is the one found first in the path (though I suspect it will be), then try again