Can't locate Moo.pm in #INC - perl

I am trying to run a .pm program in dzsoft perl editor. but i got this error
Can't locate Moo.pm in #INC (#INC contains: C:\Users\123\Desktop\ C:/Perl64/site/lib C:/Perl64/lib .) at UniNE.pm line 5.
My interpertor is ActivePerl-5.18.2.1802-MSWin32-x64-298023
how can I add moo.pm to lib?

This error means you've got a line that says use Moo; and it can't find it. The first question is - have you installed 'Moo'? If not, then:
perl -MCPAN -e shell
install Moo
This may take a bit of faffing with ActivePerl, so you may want to try and use ppm instead. If you do definitely have it installed, then I would suggest the next port of call is to try and figure out where it ended up - search for Moo.pm in your local filesystem, and compare that against your #INC path. You may find permissions are the root cause, and it's unreadable by your perl user.

I should install Moo module first. Try from cmd-line: cpan Moo

Related

Can't locate [module] in #INC... but it's there

Context
I'm working in an offline environment, so no CPAN.
My goal is to utilize OAuth.pm
I manually installed Crypt::OpenSSL::RSA.
Problem
Can't locate Crypt/OpenSSL/RSA.pm in #INC (#INC contains: /usr/local/lib64/perl5 .)
#INC is truncated
I can see RSA.pm in /usr/local/lib64/perl5/Crypt/OpenSSL/... so I'm not sure how to troubleshoot this one.
This is after manually running make install
I assume you are trying to run the script OAuth.pl (?).. Then the module OAuth.pm is in the same directory as the script and you need to add the current directory to #INC for the script to see the module:
perl -I. OAuth.pl # I. --> add current directory to #INC
See Doesn't Perl include current directory in #INC by default? for more information.
Note: I tried to run the script but it still failed due to syntax errors. Here is a patch that seems to fix the errors.

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

Openshift Perl dependencies not loading from .openshift/cpan.txt

I have reviewed the dependency documentation found here:
https://help.openshift.com/hc/en-us/articles/202185484-Adding-dependencies-to-applications
And reviewed the information on .openshift/cpan.txt replacing deplist.txt found here:
https://developers.openshift.com/en/perl-overview.html#_template_repository_layout
I have attempted to use the following file in both locations
File::Slurp
File::Path
File::Basename
DBI
XML::Simple
Moose
However the build does not seem to recognize these dependencies. The build does not report errors, but the cpan modules are not available.
[myapp-mydomain.rhcloud.com]\> perl -e "use File::Slurp"
Can't locate File/Slurp.pm in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
This is a php application with mySql and phpMyAdmin cartridges but I have not found any way to add a "Perl Cartridge" and I saw a post (can't find the link) that indicated it was not necessary as perl was available with all apps. I think I'm missing something somewhere, maybe a Perl cartridge or configuration file is necessary, or maybe headers other content needed in the cpan.txt file? The documentation indicates that the cpan.txt file should "look something like this" - but I could not find anything that gave a real file format spec.
Thanks in advance for your help.
Since you are using the PHP cartridge, you will not be able to automatically install Perl modules using the above methods. That only works on the Perl cartridge. You can try sshing into your gear and running the "perl -MCPAN -e shell" manually, but you might not have write access to the ~/.cpan directory on your gear, so that may not work either. If you can provide more information about what you are trying to do someone might have a suggested solution.

Using XPath with Perl

I am trying to replicate what my C#/XPath code does on Linux using Perl. I copied and pasted the code in Example 8-6 in Perl & XML. If I understand right, I should be able to run that Perl code, put this code in terminal
xmlPerl.pl mydatafile.xml "/inventory/category/item/name"
But when I try to run the Perl file, it doesn't work. Here is the error:
[root#Perl ~]# perl xmlPerl.pl
Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at xmlPerl.pl line 3.
BEGIN failed--compilation aborted at xmlPerl.pl line 3.
What am I doing wrong? I think it has something to do with the XML and XPath names in the beginning of my code. Do I need to install something to use the XPath framework? I am running on RedHat 5.5.
From perldiag:
Can't locate %s
You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in #INC, unless the file name included the full path to the file. Perhaps you need to set the PERL5LIB or PERL5OPT environment variable to say where the extra library is, or maybe the script needs to add the library name to #INC. Or maybe you just misspelled the name of the file. See require in perlfunc and lib.
You don't have installed XML::XPath module, or Perl not found it. Install module with CPAN:
> cpan XML::XPath
or with package manager:
> apt-get install libxml-xpath-perl
Or if it already installed say where it is with PERL5LIB environment variable:
> PERL5LIB=/path/to/lib perl ...
#INC variable:
BEGIN {
unshift(#INC, '/path/to/lib');
}
or lib pragma:
use lib '/path/to/lib';
That's the standard error that comes from trying to use a module that isn't installed. You should install it.
Ideally use the OS package for it; for example on a debian-derived OS (such as Debian or Ubuntu)
$ apt-get install libxml-xpath-perl
Failing that, you can install it as usual using CPAN
$ cpan XML::XPath
The answer is in the first part of your error:
Can't locate XML/XPath.pm
In Perl, the huge benefit is from using modules, or libraries, that others have written for you and you can reuse. In this case, someone has written a module called XML::XPath (in Perl, the path is delineated by '::') and you just need to install it. The easiest way to install it is via cpan, it's a tool that comes installed with most Perl installations. Just run:
cpan
(you'll be dropped into a different command prompt)
install XML::XPath
This will go out and fetch XML::XPath, unpack it, generate the Makefile, check for dependencies (and install any that are missing), make it, test it, and install it for you. Look here for more information on using CPAN.

Can't locate LWP/Simple.pm in #INC [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What's the easiest way to install a missing Perl module?
I'm attempting to run a Perl script to convert SCXML to Graphviz DOT. I modified the first line of the script to:
#!/usr/bin/env perl
and chmod +x the file. When I run it via ./scmxl2dot.pl I see the following error output:
Can't locate LWP/Simple.pm in #INC (#INC contains: /opt/local/lib/perl5/site_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/site_perl/5.12.3 /opt/local/lib/perl5/vendor_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/vendor_perl/5.12.3 /opt/local/lib/perl5/5.12.3/darwin-multi-2level /opt/local/lib/perl5/5.12.3 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl .) at ./scmxml2dot.pl line 14.
BEGIN failed--compilation aborted at ./scmxml2dot.pl line 14.
Line 14 of the file is use LWP::Simple;
How do I:
Find out if I have this thing (module?) installed, and/or
Get LWP::Simple and make it available to the script?
This is running under OS X 10.7.3 and Perl 5.12.3 (as seen in the error).
You're already determined that you don't have it (somewhere it can be found).
perl -MCPAN -e'install "LWP::Simple"'
Execute the following from the command line:
perl -MLWP::Simple -e 1
If you don't get any output from the above command then the module is installed; if you get an error, it's not installed
to install use
perl -MCPAN -e'install "LWP::Simple"'
When perl encounters use My::Module it goes over the elements of the built-in #INC module that contains directory names. In each directory it check if there is a subdirectory called "My" and if in that subdirectory there is a file called "Module.pm".
check where LWP::Simple module is installed on your system and type below line just above the use LWP::Simple statement of your code.
use lib '/usr/local/module';
use LWP::Simple;
Take a look at the Perldoc webpage. This will tell you which modules are standard Perl modules and which ones aren't.
You can also use the perldoc command to find out if a Perl module is installed, and if it is, its documentation.
$ perldoc LWP::Simple
(If Perldoc doesn't execute as a command do ls -l /usr/bin/perl*. On Macs, some of the Perl commands don't have the execute bit turned on. To turn it on, do sudo chmod a+x /usr/bin/perl).
It just happens the LWP::Simple isn't a standard Perl module, and if you don't have it, you'll have to install it. Most people have already told you about cpan. Unfortunately, by default, the Mac doesn't have the needed command line development tools installed. You'll have to install them.
Once they're installed, you can use the cpan command to install LWP::Simple:
$ sudo cpan #Run cpan and configure it. It takes about 3 minutes
cpan> install LWP::Simple
cpan> exit