I have Perl Module ( Net::Telnet
) is been installed in location: /home/vinod/VK_Scripts/Practices/lib
I am executing below command to check if the module exists in system or not using below command -
perl -MNet::Telnet -e 'print "Installed\n"'
vinod@vinod-VirtualBox:~/VK_Scripts/Practices$ perl -MNet::Telnet -e 'print "Installed\n"'
Can't locate Net/Telnet.pm in @INC (you may need to install the Net::Telnet module) (@INC contains: /home/vinod/perl5/lib/perl5/5.30.0/x86_64-linux-gnu-thread-multi /home/vinod/perl5/lib/perl5/5.30.0 /home/vinod/perl5/lib/perl5/x86_64-linux-gnu-thread-multi /home/vinod/perl5/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base).
BEGIN failed--compilation aborted.
So, I have added the lib path to PERL5LIB as suggested by @ikegami in this thread.
Command was -
export PERL5LIB=/home/vinod/perl5/lib/perl5:/home/vinod/VK_Scripts/Practices/lib
And now when I check with same command whether module exists in system or not by using below command it returns true.
vinod@vinod-VirtualBox:~/VK_Scripts/Practices$ perl -MNet::Telnet -e 'print "Installed\n"'
Installed
So, question here is is there any possibility I can check whether module is exists in possible location in perl -MNet::Telnet -e 'print "Installed\\n"'
command itself rather export
them to PERL5LIB
before.
You can specify the include path (one or multiple) for the Perl interpreter on the command line itself by the -I parameter:
perl -I /home/vinod/VK_Scripts/Practices/lib -MNet::Telnet -e ''
You can also inspect the exit code of your script. If it is installed it will be zero, otherwise you got something than zero.
Installation of perl module can be confirmed with following command
cpan -D {module}
output of this command looks like following cpan -D Net::Telnet
C:\...\Examples>cpan -D Net::Telnet
Loading internal logger. Log::Log4perl recommended for better logging
CPAN: CPAN::SQLite loaded ok (v0.217)
CPAN: LWP::UserAgent loaded ok (v6.43)
Fetching with LWP:
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz
CPAN: YAML::XS loaded ok (v0.81)
Fetching with LWP:
http://cpan.strawberryperl.com/modules/02packages.details.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/03modlist.data.gz
Database was generated on Sat, 22 Aug 2020 09:40:39 GMT
Updating database file ... Done!
Net::Telnet
-------------------------------------------------------------------------
CPAN: Module::CoreList loaded ok (v5.20200314)
(no description)
J/JR/JROGERS/Net-Telnet-3.04.tar.gz
C:\bin\Portable\strawberry-perl\perl\vendor\lib\Net\Telnet.pm
Installed: 3.04
CPAN: 3.04 up to date
Jay Rogers (JROGERS)
jay@rgrs.com
Note: if module installed in none default location, as for example on web server which is not under your control (into your home directory), you have to define variable PERL5LIB
to point installation location, to be included into @INC
or in perl script(s) utilize use lib ....
.
Note: perl command option -I
allows to specify include directory to look into. If you do not mind to type long path then you can use it, although including this path into @INC
is preferable approach. In last case you can make script executable and just type script.pl [options] file(s)
.
Documentation: perlrun
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.