13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX■ ■ ■Perl TipsSee recipes 1-5 to 1-7 for some discussions of good scripting habits. Here are a few more Perl notes thatyou may find helpful.Perl Modules and CPANOne of the most useful things to know about for Perl is CPAN (http://cpan.org), the repository of Perlmodules. To install a module directly from CPAN, use this command line (ideally as root):# perl -MCPAN -e "install Module::Name"However, if possible, it’s better to install the module as a Debian/Ubuntu package because you’ll getany updates automatically (when the package is updated) and because it also becomes easier to managethe install or removal of the module. Numerous Perl modules are already available as packages, and areasonably large number of modules are included in the standard Perl install. To check whether amodule is installed already, use this one-liner from the command line:> perl -e "use Module::Name"No output indicates that the module is present; if it’s not present, you’ll get a “Can’t locateModule::Name” message.If the module isn’t installed already, the next step is to see whether it’s available as a package. Thestandard Debian/Ubuntu naming convention is for the package containing the module Module::Name tobe called libmodule-name-perl (so Authen::SASL is libauthen-sasl-perl), so try sudo apt-get installlibperl-module-name.If the module doesn’t already exist as a Debian package, a more maintainable alternative toinstalling directly from CPAN is to package it yourself using the dh-make-perl package (later you’ll alsoneed the devscripts package, so the following installs that as well):> sudo apt-get install dh-make-perl devscriptsNext, download and unpack the module source. My example module here is Finance::Bank::Smile,which is an interface to online banking for my U.K. bank, Smile. The CPAN page is http://search.cpan.org/~rpanman/Finance-Bank-Smile-0.05/, so I download and unpack the source and then generatethe files needed to create the package:247Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!