Programmers are notorious for writing the code first and the documentation never, so the designers of Perl built in a
documentation system which makes writing documentation so easy that anyone can and will do so. The name of the built
in system is pod which stands for plain old documentation. It allows you to embed
documentation right in your program using a very simple markup format. The markup tags serve several purposes:
Along with Perl are shipped several translators that filter generic pod format into specific output styles. These include pod2man to change your pods into troff for use with the UNIX man program or for phototypesetting and printing; pod2html for creating web pages (which works even on non-Unix systems); and pod2text for plain ASCII. Other translators, like pod2ipf, pod2fm, pod2texi, pod2latex, and pod2ps, may also be available or can be found on CPAN (the Certified Perl Archive Network).
A pod translator reads a file paragraph by paragraph, ignoring text that isn't pod, and converting pod text to the proper format. Paragraphs are separated from each other by blank lines (not just by a newline). The various translators recognize three kinds of paragraphs:
Commands begin with =, followed immediately by the command identifier, e. g., =cut They can also be followed by text: =head2 Second-level heading A blank line signals the end of the command.
A paragraph consisting of a block of text, generally filled and possibly justified, depending on the translator. For example, a command like =head2 is probably going to be followed with a text paragraph: =head2 Pod Pod is a simple, but surprisingly capable, text formatter that uses tags to tell a translator how to format the text.
A paragraph that is to be reproduced as-is, with no filling or justification. To create a verbatim paragraph, indent each line of text with at least one space: Don't fill this paragraph. It's supposed to look exactly like this on the page. There are blanks at the beginning of each line.
The following paragraph tags are recognized as valid pod commands:
In addition to the paragraph tags (above), pod has a set of tags that apply within text, either in a paragraph or a command. For information on those tags, see the Perl built-in documentation available by entering perldoc perlpod at your MS DOS or UNIX Perl command prompt.
I highlighted the pod2html reference above because I think that it's the neatest translator. The
following two links are to an actual "live" example of pod2html output and the perl program from which it was generated:
sort.html sort.pl (text file [so that it does not execute the Perl script])Again, additional information on its usage can be had by entering perldoc pod2html at your MS DOS or UNIX Perl command prompt.
In our next to the last lesson for this module, we will sum up our stroll through Perl.
See you next lesson!
=back
=over
.
Ends the innermost =over / =back
block of indented text. If there are
multiple levels of indent, one =back
is needed for each level.=begin
=begin format
=begin html
A =begin / =end
block is like =for
except that it
doesn't necessarily apply to a single paragraph.=cut
pod
text. Tells the compiler that there isn't
any more pod (for now) and to start compiling again.=end
=begin
block. Tells the translator to treat what follows as pod
again.=for
=for format
=head1
=head1 text
=head2
=head2 text
=item
=item text
=over / =back
block.
Many translators use the value of text on the first =item
to determine the type of list:=item *
*
) is commonly used for
the bullet, but can be replaced with any other single character.
Followed by a blank line and then the text of the bulleted item:
=item * This is the text of the bullet.
=item n
1
on the
first item, 2
on the second, and so on - pod does
not automatically generate the numbers.=item text
The exact appearance of the output depends on what translator you use, but it will look pretty much like this:=item <HTML> Indicates the beginning of an HTML file
<HTML> Indicates the beginning of an HTML file
=over n
=over 4
will indent four spaces. Another
=over
before a =back
creates nested lists. The
=over
tag should be followed by at least one =item
.
=pod
pod
text. A translator starts to pay
attention when it sees this tag, and the compiler ignores everything from there to the next
=cut