Need help for cpan installation and module directory - perl

I'm trying to install perl module. But, I have this error:
"Can't find C:\Strawberry\perl\bin\cpan.bat on PATH, '.' not in PATH".
And, when I use cpan from strawberry directory and try to install module, perl can't find it.

Please confirm these process done by you in your machine.
Go the System properties and Click ENVIRONMENT Variables
Add your Strawberry perl path in USER variables C:\Strawberry\perl\bin
Add your Strawberry perl path in SYSTEM variables C:\Strawberry\perl\bin
I hope this is clear for you.

Related

Perl Module install to mentioned directory

I want to install a Perl module to a particular directory which I am mentioning while executing a command.
I want this module to be installed in a mentioned path.
Command I tried is
$ env PERL_MM_OPT='INSTALL_BASE=/home/vinod/my_test_folder/perl_practice/scripts' cpanm Log::Log4perl
But this by default installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/perl5.
What could be the reason? How to install the module in particular directory which I am mentioning?
See the documentation of INSTALL_BASE. You seem to be interested in changing just the INSTALLPRIVLIB path. Maybe you want to set the LIB attribute only, described in the next section?

Perl cpan installed modules are installed with an individual lib path

Installing with the cpan cli tool modules - they are not found at script execution time basically as part of the #INC directories. I am using cygwin.
/home/myuser/.local/share/.cpan/build/Email-Sender-1.300031-0/lib/Email/Sender/Simple.pm
/home/myuser/.local/share/.cpan/build/Email-Simple-2.216-0/lib/Email/Simple.pm
I could now reference each single lib directory (they differ with each module installation) using the PERL5LIB Variable which is dull and boring. Am I doing something wrong? I want to install Perl Modules with cpan and use them afterwards without care where they are located...
All the module installation failed because the 'make' utility was not installed.
Now the cpan modules get installed and can be used within my scripts.

Perforce P4Perl Api installs in wrong directory

I have two Perl versions installations on my PC, 5.12.3 and 5.16.3. To install the P4Perl API, I needed to set in Path the location of Perl 5.16.3(otherwise I was getting a P4Perl API installer error) and after succesfully running the installation, I searched for the P4.pm module and noticed that the installation of the P4.pm module was done in the folder of the 5.12.3 installation.
As you can see in the title, the installation was done for Perl 5.16
But if I search for the P4.pm, it is located in the 5123 folder ( which is coresponding to Perl 5.12.3
Even more, when I try to run a simple script which only imports the P4.pm module:
-with Perl 5.16.3 it complains about the missing P4.pm module
-with Perl 5.12.3 it complains about the missing perl516.dll which I can find with Everything in the installation of Perl 5.16.3.
After this, I thought to move the content which was installed in 5.12.3 installation to the 5.16.3 installation, just as #Gerhard suggested. And now it works. Does anyone knows why it messes up at installation?
Even though, the files exist physically.
Copy the Directories of the module files to the <PATH_TO_PERL>/lib and <PATH_TO_PERL>/site/lib to solve the issue.
Perl modules almost always exists as /lib/DIR/DIR/Module.pm
for instance C:\perl64\lib\Date\Simple\date.pm
If the files exists on their own, the there is a problem with the module installation itself. Or, Somewhere there is a path reference to your old perl version directory.
To see which perl path is used by default, do:
perl -e "print $^X"
Hope that helps a bit.

Perl - Use lib with perl module which have dependencies

I have a Perl script which uses the module Net::SSH::Any. Since it does not belong to the “default” Perl installation, I have to use the use lib functionality to include it in my script.
Now, I have the directory c:\lib\net\ssh\any\ on my drive and I specify this: use lib c:/lib; at the beginning of my script.
It “works”: it didn’t say that the module is missing but it says that it couldn’t locate auto/Net/SSH2/autosplit.ix and at the end no backend available at...
When I add the auto directory (containing the correct structure) in the c:\lib\ directory and launch the script, I get this error:
No backend available at...
Which is an internal error of Net::SSH::Any mentioning it could not access the backend directory (which is already included :/)
Does anyone know how to solve something like that? I hope I was clear enough.
You need to use Local::Lib.
This will let you install and load a whole bunch of libraries and their dependencies in an alternate location. I use cpanm to manage my modules and a command something like this (which I put in a wrapper script).
cpanm -L $cpandir $M --no-skip-installed
Where $cpandir is your locallibdir and $M is the module you are trying to install.
Then in your code you would specify
use local::lib '~/foo';
However, I recommend setting a PERL5LIB environment variable, which will append your custom location to #INC and make the extra use local::lib line unnecessary. You would typically edit .bashrc or .profile in your home directory with a line like:
export PERL5LIB=/home/myusername/mymods/
The issue was caused by the fact that the module was downloaded and installed on a 32bits windows but I tried to run it on a perl 64bits installation! So the Net::SSH2 required module couldn't be executed properly.
To resume:
-How to detect the issue: by executing this command: (thanks to Salva)
"perl -Ic:\lib -MNet::SSH2 -e1"
-Modules definitions in my script:
use lib 'c:\lib';

Install script for perl script

I have simple perl script and I want to make install script which install dependencies (perl modules) and copy my file.perl to /usr/share/path asking about password if necessary. I found that there are some solutions for installing perl modules (Makefile.PL, Build.PL etc.). But my script isn't module. How should I attempt it?
Makefile.PL/ExtUtils::MakeMaker support a EXE_FILES parm for perl script, you can see how App::Ack do this or check this tutorial. Just set the prefix to your directory and it should do the work for you.