Core Perl documentation and CPAN module documentation

Perl comes with a lot of documentation and with some tutorials but it takes some time till you get used to using it. In this part of the Perl tutorial I'll explain how to find your way around.

perldoc in the web

The most convenient way to access the documentation of core perl is to visit the perldoc web site.

It contains an HTML version of the documentation of Perl, the language and the modules that come with core Perl, as released by the Perl 5 Porters.

It does not contain documentation of the CPAN modules. There is an overlap though as there are some modules that are available from CPAN but are also included in the standard Perl distribution.

You can use the search box at the top right corner. For example you can type in split and you'll get the documentation of split.

Unfortunately it does not know what to do with while nor with $_ or @_. In order to get explanation about those you'll have to flip through the documentations.

The most important one might be perlvar where you can find information about variables such as $_ and @_.

perlsyn explains the syntax of Perl including that of the while loop.

perldoc on the command line

The same documentation comes with the source code of Perl but not every Linux distribution installs it by default. In some cases there is a separated package. For example in Debian and Ubuntu it is the perl-doc package. You need to installed it using sudo aptitude install perl-doc before you can use perldoc.

Once you have it installed you can type perldoc perl on the command line and you will get some explanation and a list of the chapters in the Perl documentation. You can quit this using the q key and then type the name of one of the chapters. For example: perldoc perlsyn.

This works both on Linux and on Windows though the pager on Windows is really weak so I cannot recommend it. On Linux it is the regular man reader so you should be familiar with it already.

Documentation of CPAN modules

Every module on CPAN comes with documentation and examples. The amount and quality of this documentation varies greatly among the authors and even a single author can have very well documented and very under-documented modules.

After you installed a module you can access its documentation by typing perldoc Module::Name.

There is a more convenient way though that does not even need the module to be installed. There are several web interfaces to CPAN. I'd point out Meta CPAN and search CPAN.

They both are based on the same documentation but they provide slightly different experience.

Next

The next part is about POD - Plain Old Documentation.


Perl tutorial and video course

For further articles see the Beginner Perl Maven tutorial book and video course.


In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
blog comments powered by Disqus
Online courses:


Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed