start page | rating of books | rating of authors | reviews | copyrights

Unix Power ToolsUnix Power ToolsSearch this book

41.10. Perl Boot Camp, Part 7: perldoc

We all need a little help sometimes, and it's at those times that perldoc comes in handy. Normally, core Perl and module documentation is accessible through your system's manpage system, but you can also use the perldoc program, which has a few convenient features that you should be aware of. Like man, perldoc takes the name of a module or core Perl document as an argument.

Your system's perl comes bundled with hundreds of pages of very readable documentation. The top of the document tree can be accessed with either perldoc perl or man perl. This page is little more than a table of contents[126] for the rest of the perl documentation. There are over 40 documents listed there, but there are a couple that will be immediately useful to novice Perl programmers, as Table 41-10 shows.

[126]There's actually a more complete table of contents available: man perltoc.

Table 41-10. Frequently used Perl manpages

Name

Description

perlsyn

The complete guide to Perl syntax

perldata

Perl's data types explained

perlop

Perl's operators and their precedence

perlfunc

The complete guide to all of Perl's built-in functions

perlre

The complete guide to Perl's regular expressions

In many cases (such as the ones above), perldoc doesn't do anything man can't. However with perldoc, you can easily look up built-in Perl functions with the -f flag (-t formats any POD elements for a text console). For instance, to see the entry on print, try this:

$ perldoc -tf print

You'll get back something like the following (which has been abbreviated):

print FILEHANDLE LIST
print LIST
print   Prints a string or a list of strings.  Returns
        true if successful.  FILEHANDLE may be a scalar
        variable name, in which case the variable contains
        the name of or a reference to the filehandle, thus
        introducing one level of indirection.
         ...

Perl has quite a large FAQ. You can read each of the nine sections (perlfaq1 through perlfaq9) to find the answer to your question or you can use the -q flag to keyword search all of the FAQ.

$ perldoc -q fork
Found in /usr/local/lib/perl5/5.6.1/pod/perlfaq8.pod
       How do I fork a daemon process?

       If by daemon process you mean one that's detached (disas-
       sociated from its tty), then the following process is
       reported to work on most Unixish systems.  Non-Unix users
       should check their Your_OS::Process module for other solu-
       tions.
       ...

Do take advantage of the copious documentation already on your system: you will be reward many times over.

-- JJ



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.