Perl 中的 POD 是什麼?


Pod 是一種易於使用的標記語言,用於編寫 Perl、Perl 程式和 Perl 模組的文件。有很多可用的轉換器可以將 Pod 轉換成多種格式,如純文字、HTML、手冊頁等。Pod 標記包含三種基本型別的段落 -

  • 普通段落 - 可以使用格式程式碼在普通段落中設定粗體、斜體、程式碼樣式、超連結等。
  • 逐欄位落 - 逐欄位落通常用於顯示不需要任何特殊解析或格式的程式碼塊或其他文字,並且不應該進行換行。
  • 命令段落 - 命令段落用於對大段文字進行特殊處理,通常用作標題或列表的部件。所有命令段落都以 = 開頭,後跟一個識別符號,再後跟任意文字,命令可以隨意使用該文字。目前已識別到的命令為 -
=pod
=head1 Heading Text
=head2 Heading Text
=head3 Heading Text
=head4 Heading Text
=over indentlevel
=item stuff
=back
=begin format
=end format
=for format text...
=encoding type
=cut

POD 示例

考慮以下 POD -

=head1 SYNOPSIS
Copyright 2005 [TUTORIALSOPOINT].
=cut

可以使用 Linux 上的 pod2html 實用程式將上述 POD 轉換成 HTML,這樣它將生成以下結果 -

版權所有 2005 [TUTORIALSOPOINT]

接下來,考慮以下示例 -

=head2 An Example List
=over 4
=item * This is a bulleted list.
=item * Here's another item.
=back
=begin html
<p>
Here's some embedded HTML. In this block I can
include images, apply <span style="color: green">
styles</span>, or do anything else I can do with
HTML. pod parsers that aren't outputting HTML will
completely ignore it.
</p>
=end html

使用 pod2html 將上述 POD 轉換成 HTML 時,它將生成以下結果 -

An Example List
This is a bulleted list.
Here's another item.
Here's some embedded HTML. In this block I can include images, apply
styles, or do anything else I can do with HTML. pod parsers that aren't
outputting HTML will completely ignore it.

更新時間:2019 年 12 月 2 日

517 次瀏覽

開啟你的職業生涯

完成課程以獲得認證

開始學習
廣告
© . All rights reserved.