Книга: Fedora™ Unleashed, 2008 edition
Modules and CPAN
Modules and CPAN
A great strength of the Perl community (and the Linux community) is that it is an open source community. This community support is expressed for Perl via CPAN, which is a network of mirrors of a repository of Perl code.
Most of CPAN is made up of modules, which are reuseable chunks of code that do useful things, similar to software libraries containing functions for C programmers. These modules help speed development when building Perl programs and free Perl hackers from repeatedly reinventing the wheel when building a bicycle.
Perl comes with a set of standard modules installed. Those modules should contain much of the functionality that you will initially need with Perl. If you need to use a module not installed with Fedora, use the CPAN module (which is one of the standard modules) to download and install other modules onto your system. At http://www.perl.com/CPAN, you will find the CPAN Multiplex Dispatcher, which attempts to direct you to the CPAN site closest to you.
Typing the following command puts you into an interactive shell that gives you access to CPAN. You can type help
at the prompt to get more information on how to use the CPAN program.
$ perl -MCPAN -e shell
After you have installed a module from CPAN (or written one of your own), you can load that module into memory, where you can use it with the use
function:
use Time::CTime;
looks in the directories listed in the variable
use@INC
for the module. In this example, use
looks for a directory called Time
, which contains a file called CTime.pm
, which in turn is assumed to contain a package called Time::CTime
. The distribution of each module should contain documentation on using that module.
For a list of all the standard Perl modules (those that come with Perl when you install it), see perlmodlib
in the Perl documentation. You can read this document by typing perldoc perlmodlib
at the command prompt.
Related Fedora and Linux Commands
You will use these commands and tools when using Perl with Linux:
? a2p
— A filter used to translate awk
scripts into Perl
? find2perl
— A utility used to create Perl code from command lines, using the find command
? pcregrep
— A utility used to search data, using Perl-compatible regular expressions
? perlcc
— A compiler for Perl programs
? perldoc
— A Perl utility used to read Perl documentation
? s2p
— A filter used to translate sed
scripts into Perl
? vi
— The vi
(actually vim
) text editor
- Разработка приложений баз данных InterBase на Borland Delphi
- Open Source Insight and Discussion
- Introduction to Microprocessors and Microcontrollers
- Chapter 6. Traversing of tables and chains
- Chapter 8. Saving and restoring large rule-sets
- Chapter 11. Iptables targets and jumps
- Chapter 5 Installing and Configuring VirtualCenter 2.0
- Chapter 16. Commercial products based on Linux, iptables and netfilter
- Appendix A. Detailed explanations of special commands
- Appendix B. Common problems and questions
- Appendix E. Other resources and links
- IP filtering terms and expressions