Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Perl POD Documentation

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

print

"

Hello, World

\n

"

;

=head1

Hello, World Example This is a simple Perl example.

=cut

print

"

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

print

"

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

print

"

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.

=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: