Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

installing Perl Modules 2

Status
Not open for further replies.

nix45

MIS
Nov 21, 2002
478
US
On Linux systems, how do you normally install Perl modules that you download as .pm files? For example, I recently downloaded Net::Telnet::Cisco and I placed the Cisco.pm file in the /usr/lib/perl5/5.8.0/Net/ directory. I got this to work, but this can't be the right way to do it. In the script, I had to....

use Net::Cisco;
$session = Net::Telnet::Cisco->new(Host => $router);

I'm trying to install another module now to generate random passwords, String::Random. I placed the Random.pm file in /usr/lib/perl5/5.8.0/ and in the script...

use Random;
$pass = new String::Random;
print "Your password is ", $pass->randpattern("CCcc!ccn"), "\n";

This can't be right, what is the proper way of doing this?

Thanks,
Chris
 
Net::Telnet::Cisco should be located at
/usr/lib/perl5/5.8.0/Net/Telnet/Cisco.pm

String::Random at:
/usr/lib/perl5/5.8.0/String/Random.pm

The :: is a way of representing a directory seperator (i.e. '/' in *nix)
 
Ok, that worked for String::Random, but not Net::Telnet::Cisco. The scripts that use Cisco.pm work, but I get an error when I run them....

Can't locate auto/Net/Telnet/Cisco/autosplit.ix in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at /usr/lib/perl5/5.8.0/AutoLoader.pm line 160.
at /usr/lib/perl5/5.8.0/Net/Telnet/Cisco.pm line 18


Thanks,
Chris
 
You're safer to install using CPAN.pm or CPANPLUS.pm, as Net::Telnet::Cisco requires autoloader magic. In fact it is safer to do this with every module you install for 3 good reasons:

1) The distribution will (usually) include everything you need to install the module(s) you require
2) The CPAN/CPANPLUS installers will handle prerequisites.
3) Installers TEST distributions first.

#2 can save you *a lot* of time and effort, as both installers will ask you whether you wish to install the prerequisites if they aren't on your system, and go away and install them too.

#3 is probably the most worthwhile reason for using the installers. If anything goes wrong, such as the particular version of a module you want to install has a bug, you really don't want to install the module just in case it has bad consequences.

For more details on installing with CPAN or CPANPLUS see faq219-1687 (I know it says Win32, but CPAN & CPANPLUS are applicable to all OSs).

Barbie
Leader of Birmingham Perl Mongers
 
Thanks, thats what I was looking for. I forgot how to use cpan to install modules. I was typing 'cpan' from the shell, I forgot it was 'perl -MCPAN -e shell'.

Chris
 
What was the command to see all installed modules?
 
I don't see anything from the CPAN prompt that shows this...

cpan> help

Display Information
command argument description
a,b,d,m WORD or /REGEXP/ about authors, bundles, distributions, modules
i WORD or /REGEXP/ about anything of above
r NONE reinstall recommendations
ls AUTHOR about files in the author's directory

Download, Test, Make, Install...
get download
make make (implies get)
test MODULES, make test (implies make)
install DISTS, BUNDLES make install (implies test)
clean make clean
look open subshell in these dists' directories
readme display these dists' README files

Other
h,? display this menu ! perl-code eval a perl command
o conf [opt] set and query options q quit the cpan shell
reload cpan load CPAN.pm again reload index load newer indices
autobundle Snapshot force cmd unconditionally do cmd
cpan>
 
From Duncan's post 2004-04-19
from the command line: perl -e 'print "@INC";'

My own CPAN is screwed, need to rebuild but it should be one of the options at the start

--Paul


 
yeah, I just saw that, I had it marked for notification:) I thought the @INC array only showed which directories Perl will search for modules in? If so, I guess I could write a script that will display all the files in each of those directories.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top