Perl POD Documentation
In Perl, POD (Plain Old Documentation) can be embedded in modules or scripts.
POD is a simple and easy-to-use markup language.
POD documentation usage rules:
POD documentation begins with =head1 , =cut ends with =head1 A blank line should be added before =cut and after .
Perl ignores the documentation in POD. Example below:
Example
#!/usr/bin/perl
"
Hello, World
\n
"
;
=head1
Hello, World Example This is a simple Perl example.
=cut
"
Hello, Runoob
\n
"
;
Running the above program, the output is:
Hello, World
Hello, Runoob
We can also use "END" or "DATA" to "comment out" all content after the line where they appear:
Example
#!/usr/bin/perl
"
Hello, World
\n
"
;
while
(
<
DATA
)
{
print
$_;
}
END
=head1
Hello, World Example This is a simple Perl example. print "Hello, Runoob\n";
Running the above program, the output is:
Hello, World
=head1 Hello, World 实例
这是一个 Perl 的简单实例。
print "Hello, Runoob\n";
The following example does not read the POD documentation:
Example
#!/usr/bin/perl
"
Hello, World
\n
"
;
END
=head1
Hello, World Example This is a simple Perl example. print "Hello, Runoob\n";
Running the above program, the output is:
Hello, World
What is POD?
Pod (Plain Old Documentation) is a simple and easy-to-use markup language, often used for writing documentation in Perl programs and modules.
Pod's converters can convert Pod into many formats, such as text, html, man, and many others.
The Pod markup language contains three basic types: ordinary, verbatim, and command.
-
Ordinary paragraphs: You can use formatting codes in ordinary paragraphs, such as bold, italic, code style, underline, and so on.
-
Verbatim paragraphs: Verbatim paragraphs are used for code blocks or other parts that do not need to be processed by the converter, and they do not need paragraph reflow.
-
Command paragraphs: Command paragraphs apply to the entire document and are usually used for heading settings or list marking.
All command paragraphs (which are only one line long) begin with "=" followed by an identifier. The subsequent text will be affected by this command. The commands widely used now include
=pod (开始文档)
=head1 heading text =head2 heading text =head3 heading text =head4 heading text =over number of indent spaces =item prefix =back (end list) =begin document format =end end document format =for format text =encoding encoding type =cut (end of document)
In Perl, you can use pod2html .pod >.html to generate POD documentation in HTML format.
Consider the following POD example:
Example
=begin
html =encoding utf-8 =head1 Runoob Tutorial
=cut
pod2html copies this piece of code verbatim.
Execute with the pod2html command to convert it into HTML code:
$ pod2html test.pod > test.html
Open test.html in the browser; the link section is the index, displayed as follows:

The following example writes HTML directly into a POD document:
=begin html
=encoding utf-8
Runoob Tutorial
www.runoob.com
=end html
pod2html copies this piece of code verbatim.
Execute with the pod2html command to convert it into HTML code:
$ pod2html test.pod > test.html
Open test.html in the browser; the link section is the index, displayed as follows:
