1*0Sstevel@tonic-gate 2*0Sstevel@tonic-gate=for comment 3*0Sstevel@tonic-gateThis document is in Pod format. To read this, use a Pod formatter, 4*0Sstevel@tonic-gatelike "perldoc perlpod". 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate=head1 NAME 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gateperlpod - the Plain Old Documentation format 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gate=head1 DESCRIPTION 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gatePod is a simple-to-use markup language used for writing documentation 13*0Sstevel@tonic-gatefor Perl, Perl programs, and Perl modules. 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gateTranslators are available for converting Pod to various formats 16*0Sstevel@tonic-gatelike plain text, HTML, man pages, and more. 17*0Sstevel@tonic-gate 18*0Sstevel@tonic-gatePod markup consists of three basic kinds of paragraphs: 19*0Sstevel@tonic-gateL<ordinary|/"Ordinary Paragraph">, 20*0Sstevel@tonic-gateL<verbatim|/"Verbatim Paragraph">, and 21*0Sstevel@tonic-gateL<command|/"Command Paragraph">. 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gate=head2 Ordinary Paragraph 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gateMost paragraphs in your documentation will be ordinary blocks 27*0Sstevel@tonic-gateof text, like this one. You can simply type in your text without 28*0Sstevel@tonic-gateany markup whatsoever, and with just a blank line before and 29*0Sstevel@tonic-gateafter. When it gets formatted, it will undergo minimal formatting, 30*0Sstevel@tonic-gatelike being rewrapped, probably put into a proportionally spaced 31*0Sstevel@tonic-gatefont, and maybe even justified. 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gateYou can use formatting codes in ordinary paragraphs, for B<bold>, 34*0Sstevel@tonic-gateI<italic>, C<code-style>, L<hyperlinks|perlfaq>, and more. Such 35*0Sstevel@tonic-gatecodes are explained in the "L<Formatting Codes|/"Formatting Codes">" 36*0Sstevel@tonic-gatesection, below. 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate=head2 Verbatim Paragraph 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gateVerbatim paragraphs are usually used for presenting a codeblock or 42*0Sstevel@tonic-gateother text which does not require any special parsing or formatting, 43*0Sstevel@tonic-gateand which shouldn't be wrapped. 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gateA verbatim paragraph is distinguished by having its first character 46*0Sstevel@tonic-gatebe a space or a tab. (And commonly, all its lines begin with spaces 47*0Sstevel@tonic-gateand/or tabs.) It should be reproduced exactly, with tabs assumed to 48*0Sstevel@tonic-gatebe on 8-column boundaries. There are no special formatting codes, 49*0Sstevel@tonic-gateso you can't italicize or anything like that. A \ means \, and 50*0Sstevel@tonic-gatenothing else. 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate=head2 Command Paragraph 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gateA command paragraph is used for special treatment of whole chunks 56*0Sstevel@tonic-gateof text, usually as headings or parts of lists. 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gateAll command paragraphs (which are typically only one line long) start 59*0Sstevel@tonic-gatewith "=", followed by an identifier, followed by arbitrary text that 60*0Sstevel@tonic-gatethe command can use however it pleases. Currently recognized commands 61*0Sstevel@tonic-gateare 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate =head1 Heading Text 64*0Sstevel@tonic-gate =head2 Heading Text 65*0Sstevel@tonic-gate =head3 Heading Text 66*0Sstevel@tonic-gate =head4 Heading Text 67*0Sstevel@tonic-gate =over indentlevel 68*0Sstevel@tonic-gate =item stuff 69*0Sstevel@tonic-gate =back 70*0Sstevel@tonic-gate =cut 71*0Sstevel@tonic-gate =pod 72*0Sstevel@tonic-gate =begin format 73*0Sstevel@tonic-gate =end format 74*0Sstevel@tonic-gate =for format text... 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gateTo explain them each in detail: 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate=over 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate=item C<=head1 I<Heading Text>> 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate=item C<=head2 I<Heading Text>> 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate=item C<=head3 I<Heading Text>> 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate=item C<=head4 I<Heading Text>> 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gateHead1 through head4 produce headings, head1 being the highest 89*0Sstevel@tonic-gatelevel. The text in the rest of this paragraph is the content of the 90*0Sstevel@tonic-gateheading. For example: 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate =head2 Object Attributes 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gateThe text "Object Attributes" comprises the heading there. (Note that 95*0Sstevel@tonic-gatehead3 and head4 are recent additions, not supported in older Pod 96*0Sstevel@tonic-gatetranslators.) The text in these heading commands can use 97*0Sstevel@tonic-gateformatting codes, as seen here: 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate =head2 Possible Values for C<$/> 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gateSuch commands are explained in the 102*0Sstevel@tonic-gate"L<Formatting Codes|/"Formatting Codes">" section, below. 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate=item C<=over I<indentlevel>> 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate=item C<=item I<stuff...>> 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate=item C<=back> 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gateItem, over, and back require a little more explanation: "=over" starts 111*0Sstevel@tonic-gatea region specifically for the generation of a list using "=item" 112*0Sstevel@tonic-gatecommands, or for indenting (groups of) normal paragraphs. At the end 113*0Sstevel@tonic-gateof your list, use "=back" to end it. The I<indentlevel> option to 114*0Sstevel@tonic-gate"=over" indicates how far over to indent, generally in ems (where 115*0Sstevel@tonic-gateone em is the width of an "M" in the document's base font) or roughly 116*0Sstevel@tonic-gatecomparable units; if there is no I<indentlevel> option, it defaults 117*0Sstevel@tonic-gateto four. (And some formatters may just ignore whatever I<indentlevel> 118*0Sstevel@tonic-gateyou provide.) In the I<stuff> in C<=item I<stuff...>>, you may 119*0Sstevel@tonic-gateuse formatting codes, as seen here: 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate =item Using C<$|> to Control Buffering 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gateSuch commands are explained in the 124*0Sstevel@tonic-gate"L<Formatting Codes|/"Formatting Codes">" section, below. 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gateNote also that there are some basic rules to using "=over" ... 127*0Sstevel@tonic-gate"=back" regions: 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate=over 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate=item * 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gateDon't use "=item"s outside of an "=over" ... "=back" region. 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate=item * 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gateThe first thing after the "=over" command should be an "=item", unless 138*0Sstevel@tonic-gatethere aren't going to be any items at all in this "=over" ... "=back" 139*0Sstevel@tonic-gateregion. 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate=item * 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gateDon't put "=headI<n>" commands inside an "=over" ... "=back" region. 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate=item * 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gateAnd perhaps most importantly, keep the items consistent: either use 148*0Sstevel@tonic-gate"=item *" for all of them, to produce bullets; or use "=item 1.", 149*0Sstevel@tonic-gate"=item 2.", etc., to produce numbered lists; or use "=item foo", 150*0Sstevel@tonic-gate"=item bar", etc. -- namely, things that look nothing like bullets or 151*0Sstevel@tonic-gatenumbers. 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gateIf you start with bullets or numbers, stick with them, as 154*0Sstevel@tonic-gateformatters use the first "=item" type to decide how to format the 155*0Sstevel@tonic-gatelist. 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate=back 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate=item C<=cut> 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gateTo end a Pod block, use a blank line, 162*0Sstevel@tonic-gatethen a line beginning with "=cut", and a blank 163*0Sstevel@tonic-gateline after it. This lets Perl (and the Pod formatter) know that 164*0Sstevel@tonic-gatethis is where Perl code is resuming. (The blank line before the "=cut" 165*0Sstevel@tonic-gateis not technically necessary, but many older Pod processors require it.) 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate=item C<=pod> 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gateThe "=pod" command by itself doesn't do much of anything, but it 170*0Sstevel@tonic-gatesignals to Perl (and Pod formatters) that a Pod block starts here. A 171*0Sstevel@tonic-gatePod block starts with I<any> command paragraph, so a "=pod" command is 172*0Sstevel@tonic-gateusually used just when you want to start a Pod block with an ordinary 173*0Sstevel@tonic-gateparagraph or a verbatim paragraph. For example: 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate =item stuff() 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate This function does stuff. 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate =cut 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate sub stuff { 182*0Sstevel@tonic-gate ... 183*0Sstevel@tonic-gate } 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate =pod 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate Remember to check its return value, as in: 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate stuff() || die "Couldn't do stuff!"; 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate =cut 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gate=item C<=begin I<formatname>> 194*0Sstevel@tonic-gate 195*0Sstevel@tonic-gate=item C<=end I<formatname>> 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate=item C<=for I<formatname> I<text...>> 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gateFor, begin, and end will let you have regions of text/code/data that 200*0Sstevel@tonic-gateare not generally interpreted as normal Pod text, but are passed 201*0Sstevel@tonic-gatedirectly to particular formatters, or are otherwise special. A 202*0Sstevel@tonic-gateformatter that can use that format will use the region, otherwise it 203*0Sstevel@tonic-gatewill be completely ignored. 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gateA command "=begin I<formatname>", some paragraphs, and a 206*0Sstevel@tonic-gatecommand "=end I<formatname>", mean that the text/data inbetween 207*0Sstevel@tonic-gateis meant for formatters that understand the special format 208*0Sstevel@tonic-gatecalled I<formatname>. For example, 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate =begin html 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate <hr> <img src="thang.png"> 213*0Sstevel@tonic-gate <p> This is a raw HTML paragraph </p> 214*0Sstevel@tonic-gate 215*0Sstevel@tonic-gate =end html 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gateThe command "=for I<formatname> I<text...>" 218*0Sstevel@tonic-gatespecifies that the remainder of just this paragraph (starting 219*0Sstevel@tonic-gateright after I<formatname>) is in that special format. 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate =for html <hr> <img src="thang.png"> 222*0Sstevel@tonic-gate <p> This is a raw HTML paragraph </p> 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gateThis means the same thing as the above "=begin html" ... "=end html" 225*0Sstevel@tonic-gateregion. 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gateThat is, with "=for", you can have only one paragraph's worth 228*0Sstevel@tonic-gateof text (i.e., the text in "=foo targetname text..."), but with 229*0Sstevel@tonic-gate"=begin targetname" ... "=end targetname", you can have any amount 230*0Sstevel@tonic-gateof stuff inbetween. (Note that there still must be a blank line 231*0Sstevel@tonic-gateafter the "=begin" command and a blank line before the "=end" 232*0Sstevel@tonic-gatecommand. 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gateHere are some examples of how to use these: 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate =begin html 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gate <br>Figure 1.<br><IMG SRC="figure1.png"><br> 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate =end html 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gate =begin text 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate --------------- 245*0Sstevel@tonic-gate | foo | 246*0Sstevel@tonic-gate | bar | 247*0Sstevel@tonic-gate --------------- 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate ^^^^ Figure 1. ^^^^ 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate =end text 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gateSome format names that formatters currently are known to accept 254*0Sstevel@tonic-gateinclude "roff", "man", "latex", "tex", "text", and "html". (Some 255*0Sstevel@tonic-gateformatters will treat some of these as synonyms.) 256*0Sstevel@tonic-gate 257*0Sstevel@tonic-gateA format name of "comment" is common for just making notes (presumably 258*0Sstevel@tonic-gateto yourself) that won't appear in any formatted version of the Pod 259*0Sstevel@tonic-gatedocument: 260*0Sstevel@tonic-gate 261*0Sstevel@tonic-gate =for comment 262*0Sstevel@tonic-gate Make sure that all the available options are documented! 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gateSome I<formatnames> will require a leading colon (as in 265*0Sstevel@tonic-gateC<"=for :formatname">, or 266*0Sstevel@tonic-gateC<"=begin :formatname" ... "=end :formatname">), 267*0Sstevel@tonic-gateto signal that the text is not raw data, but instead I<is> Pod text 268*0Sstevel@tonic-gate(i.e., possibly containing formatting codes) that's just not for 269*0Sstevel@tonic-gatenormal formatting (e.g., may not be a normal-use paragraph, but might 270*0Sstevel@tonic-gatebe for formatting as a footnote). 271*0Sstevel@tonic-gate 272*0Sstevel@tonic-gate=item C<=encoding I<encodingname>> 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gateThis command is used for declaring the encoding of a document. Most 275*0Sstevel@tonic-gateusers won't need this; but if your encoding isn't US-ASCII or Latin-1, 276*0Sstevel@tonic-gatethen put a C<=encoding I<encodingname>> command early in the document so 277*0Sstevel@tonic-gatethat pod formatters will know how to decode the document. For 278*0Sstevel@tonic-gateI<encodingname>, use a name recognized by the L<Encode::Supported> 279*0Sstevel@tonic-gatemodule. Examples: 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate =encoding utf8 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate =encoding koi8-r 284*0Sstevel@tonic-gate 285*0Sstevel@tonic-gate =encoding ShiftJIS 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate =encoding big5 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate=back 290*0Sstevel@tonic-gate 291*0Sstevel@tonic-gateAnd don't forget, when using any command, that the command lasts up 292*0Sstevel@tonic-gateuntil the end of its I<paragraph>, not its line. So in the 293*0Sstevel@tonic-gateexamples below, you can see that every command needs the blank 294*0Sstevel@tonic-gateline after it, to end its paragraph. 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gateSome examples of lists include: 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate =over 299*0Sstevel@tonic-gate 300*0Sstevel@tonic-gate =item * 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate First item 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gate =item * 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate Second item 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate =back 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate =over 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gate =item Foo() 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate Description of Foo function 315*0Sstevel@tonic-gate 316*0Sstevel@tonic-gate =item Bar() 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate Description of Bar function 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate =back 321*0Sstevel@tonic-gate 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate=head2 Formatting Codes 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gateIn ordinary paragraphs and in some command paragraphs, various 326*0Sstevel@tonic-gateformatting codes (a.k.a. "interior sequences") can be used: 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate=for comment 329*0Sstevel@tonic-gate "interior sequences" is such an opaque term. 330*0Sstevel@tonic-gate Prefer "formatting codes" instead. 331*0Sstevel@tonic-gate 332*0Sstevel@tonic-gate=over 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate=item C<IE<lt>textE<gt>> -- italic text 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gateUsed for emphasis ("C<be IE<lt>careful!E<gt>>") and parameters 337*0Sstevel@tonic-gate("C<redo IE<lt>LABELE<gt>>") 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate=item C<BE<lt>textE<gt>> -- bold text 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gateUsed for switches ("C<perl's BE<lt>-nE<gt> switch>"), programs 342*0Sstevel@tonic-gate("C<some systems provide a BE<lt>chfnE<gt> for that>"), 343*0Sstevel@tonic-gateemphasis ("C<be BE<lt>careful!E<gt>>"), and so on 344*0Sstevel@tonic-gate("C<and that feature is known as BE<lt>autovivificationE<gt>>"). 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate=item C<CE<lt>codeE<gt>> -- code text 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gateRenders code in a typewriter font, or gives some other indication that 349*0Sstevel@tonic-gatethis represents program text ("C<CE<lt>gmtime($^T)E<gt>>") or some other 350*0Sstevel@tonic-gateform of computerese ("C<CE<lt>drwxr-xr-xE<gt>>"). 351*0Sstevel@tonic-gate 352*0Sstevel@tonic-gate=item C<LE<lt>nameE<gt>> -- a hyperlink 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gateThere are various syntaxes, listed below. In the syntaxes given, 355*0Sstevel@tonic-gateC<text>, C<name>, and C<section> cannot contain the characters 356*0Sstevel@tonic-gate'/' and '|'; and any '<' or '>' should be matched. 357*0Sstevel@tonic-gate 358*0Sstevel@tonic-gate=over 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate=item * 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gateC<LE<lt>nameE<gt>> 363*0Sstevel@tonic-gate 364*0Sstevel@tonic-gateLink to a Perl manual page (e.g., C<LE<lt>Net::PingE<gt>>). Note 365*0Sstevel@tonic-gatethat C<name> should not contain spaces. This syntax 366*0Sstevel@tonic-gateis also occasionally used for references to UNIX man pages, as in 367*0Sstevel@tonic-gateC<LE<lt>crontab(5)E<gt>>. 368*0Sstevel@tonic-gate 369*0Sstevel@tonic-gate=item * 370*0Sstevel@tonic-gate 371*0Sstevel@tonic-gateC<LE<lt>name/"sec"E<gt>> or C<LE<lt>name/secE<gt>> 372*0Sstevel@tonic-gate 373*0Sstevel@tonic-gateLink to a section in other manual page. E.g., 374*0Sstevel@tonic-gateC<LE<lt>perlsyn/"For Loops"E<gt>> 375*0Sstevel@tonic-gate 376*0Sstevel@tonic-gate=item * 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gateC<LE<lt>/"sec"E<gt>> or C<LE<lt>/secE<gt>> or C<LE<lt>"sec"E<gt>> 379*0Sstevel@tonic-gate 380*0Sstevel@tonic-gateLink to a section in this manual page. E.g., 381*0Sstevel@tonic-gateC<LE<lt>/"Object Methods"E<gt>> 382*0Sstevel@tonic-gate 383*0Sstevel@tonic-gate=back 384*0Sstevel@tonic-gate 385*0Sstevel@tonic-gateA section is started by the named heading or item. For 386*0Sstevel@tonic-gateexample, C<LE<lt>perlvar/$.E<gt>> or C<LE<lt>perlvar/"$."E<gt>> both 387*0Sstevel@tonic-gatelink to the section started by "C<=item $.>" in perlvar. And 388*0Sstevel@tonic-gateC<LE<lt>perlsyn/For LoopsE<gt>> or C<LE<lt>perlsyn/"For Loops"E<gt>> 389*0Sstevel@tonic-gateboth link to the section started by "C<=head2 For Loops>" 390*0Sstevel@tonic-gatein perlsyn. 391*0Sstevel@tonic-gate 392*0Sstevel@tonic-gateTo control what text is used for display, you 393*0Sstevel@tonic-gateuse "C<LE<lt>text|...E<gt>>", as in: 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gate=over 396*0Sstevel@tonic-gate 397*0Sstevel@tonic-gate=item * 398*0Sstevel@tonic-gate 399*0Sstevel@tonic-gateC<LE<lt>text|nameE<gt>> 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gateLink this text to that manual page. E.g., 402*0Sstevel@tonic-gateC<LE<lt>Perl Error Messages|perldiagE<gt>> 403*0Sstevel@tonic-gate 404*0Sstevel@tonic-gate=item * 405*0Sstevel@tonic-gate 406*0Sstevel@tonic-gateC<LE<lt>text|name/"sec"E<gt>> or C<LE<lt>text|name/secE<gt>> 407*0Sstevel@tonic-gate 408*0Sstevel@tonic-gateLink this text to that section in that manual page. E.g., 409*0Sstevel@tonic-gateC<LE<lt>SWITCH statements|perlsyn/"Basic BLOCKs and Switch 410*0Sstevel@tonic-gateStatements"E<gt>> 411*0Sstevel@tonic-gate 412*0Sstevel@tonic-gate=item * 413*0Sstevel@tonic-gate 414*0Sstevel@tonic-gateC<LE<lt>text|/"sec"E<gt>> or C<LE<lt>text|/secE<gt>> 415*0Sstevel@tonic-gateor C<LE<lt>text|"sec"E<gt>> 416*0Sstevel@tonic-gate 417*0Sstevel@tonic-gateLink this text to that section in this manual page. E.g., 418*0Sstevel@tonic-gateC<LE<lt>the various attributes|/"Member Data"E<gt>> 419*0Sstevel@tonic-gate 420*0Sstevel@tonic-gate=back 421*0Sstevel@tonic-gate 422*0Sstevel@tonic-gateOr you can link to a web page: 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gate=over 425*0Sstevel@tonic-gate 426*0Sstevel@tonic-gate=item * 427*0Sstevel@tonic-gate 428*0Sstevel@tonic-gateC<LE<lt>scheme:...E<gt>> 429*0Sstevel@tonic-gate 430*0Sstevel@tonic-gateLinks to an absolute URL. For example, 431*0Sstevel@tonic-gateC<LE<lt>http://www.perl.org/E<gt>>. But note 432*0Sstevel@tonic-gatethat there is no corresponding C<LE<lt>text|scheme:...E<gt>> syntax, for 433*0Sstevel@tonic-gatevarious reasons. 434*0Sstevel@tonic-gate 435*0Sstevel@tonic-gate=back 436*0Sstevel@tonic-gate 437*0Sstevel@tonic-gate=item C<EE<lt>escapeE<gt>> -- a character escape 438*0Sstevel@tonic-gate 439*0Sstevel@tonic-gateVery similar to HTML/XML C<&I<foo>;> "entity references": 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate=over 442*0Sstevel@tonic-gate 443*0Sstevel@tonic-gate=item * 444*0Sstevel@tonic-gate 445*0Sstevel@tonic-gateC<EE<lt>ltE<gt>> -- a literal E<lt> (less than) 446*0Sstevel@tonic-gate 447*0Sstevel@tonic-gate=item * 448*0Sstevel@tonic-gate 449*0Sstevel@tonic-gateC<EE<lt>gtE<gt>> -- a literal E<gt> (greater than) 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate=item * 452*0Sstevel@tonic-gate 453*0Sstevel@tonic-gateC<EE<lt>verbarE<gt>> -- a literal | (I<ver>tical I<bar>) 454*0Sstevel@tonic-gate 455*0Sstevel@tonic-gate=item * 456*0Sstevel@tonic-gate 457*0Sstevel@tonic-gateC<EE<lt>solE<gt>> = a literal / (I<sol>idus) 458*0Sstevel@tonic-gate 459*0Sstevel@tonic-gateThe above four are optional except in other formatting codes, 460*0Sstevel@tonic-gatenotably C<LE<lt>...E<gt>>, and when preceded by a 461*0Sstevel@tonic-gatecapital letter. 462*0Sstevel@tonic-gate 463*0Sstevel@tonic-gate=item * 464*0Sstevel@tonic-gate 465*0Sstevel@tonic-gateC<EE<lt>htmlnameE<gt>> 466*0Sstevel@tonic-gate 467*0Sstevel@tonic-gateSome non-numeric HTML entity name, such as C<EE<lt>eacuteE<gt>>, 468*0Sstevel@tonic-gatemeaning the same thing as C<é> in HTML -- i.e., a lowercase 469*0Sstevel@tonic-gatee with an acute (/-shaped) accent. 470*0Sstevel@tonic-gate 471*0Sstevel@tonic-gate=item * 472*0Sstevel@tonic-gate 473*0Sstevel@tonic-gateC<EE<lt>numberE<gt>> 474*0Sstevel@tonic-gate 475*0Sstevel@tonic-gateThe ASCII/Latin-1/Unicode character with that number. A 476*0Sstevel@tonic-gateleading "0x" means that I<number> is hex, as in 477*0Sstevel@tonic-gateC<EE<lt>0x201EE<gt>>. A leading "0" means that I<number> is octal, 478*0Sstevel@tonic-gateas in C<EE<lt>075E<gt>>. Otherwise I<number> is interpreted as being 479*0Sstevel@tonic-gatein decimal, as in C<EE<lt>181E<gt>>. 480*0Sstevel@tonic-gate 481*0Sstevel@tonic-gateNote that older Pod formatters might not recognize octal or 482*0Sstevel@tonic-gatehex numeric escapes, and that many formatters cannot reliably 483*0Sstevel@tonic-gaterender characters above 255. (Some formatters may even have 484*0Sstevel@tonic-gateto use compromised renderings of Latin-1 characters, like 485*0Sstevel@tonic-gaterendering C<EE<lt>eacuteE<gt>> as just a plain "e".) 486*0Sstevel@tonic-gate 487*0Sstevel@tonic-gate=back 488*0Sstevel@tonic-gate 489*0Sstevel@tonic-gate=item C<FE<lt>filenameE<gt>> -- used for filenames 490*0Sstevel@tonic-gate 491*0Sstevel@tonic-gateTypically displayed in italics. Example: "C<FE<lt>.cshrcE<gt>>" 492*0Sstevel@tonic-gate 493*0Sstevel@tonic-gate=item C<SE<lt>textE<gt>> -- text contains non-breaking spaces 494*0Sstevel@tonic-gate 495*0Sstevel@tonic-gateThis means that the words in I<text> should not be broken 496*0Sstevel@tonic-gateacross lines. Example: S<C<SE<lt>$x ? $y : $zE<gt>>>. 497*0Sstevel@tonic-gate 498*0Sstevel@tonic-gate=item C<XE<lt>topic nameE<gt>> -- an index entry 499*0Sstevel@tonic-gate 500*0Sstevel@tonic-gateThis is ignored by most formatters, but some may use it for building 501*0Sstevel@tonic-gateindexes. It always renders as empty-string. 502*0Sstevel@tonic-gateExample: C<XE<lt>absolutizing relative URLsE<gt>> 503*0Sstevel@tonic-gate 504*0Sstevel@tonic-gate=item C<ZE<lt>E<gt>> -- a null (zero-effect) formatting code 505*0Sstevel@tonic-gate 506*0Sstevel@tonic-gateThis is rarely used. It's one way to get around using an 507*0Sstevel@tonic-gateEE<lt>...E<gt> code sometimes. For example, instead of 508*0Sstevel@tonic-gate"C<NEE<lt>ltE<gt>3>" (for "NE<lt>3") you could write 509*0Sstevel@tonic-gate"C<NZE<lt>E<gt>E<lt>3>" (the "ZE<lt>E<gt>" breaks up the "N" and 510*0Sstevel@tonic-gatethe "E<lt>" so they can't be considered 511*0Sstevel@tonic-gatethe part of a (fictitious) "NE<lt>...E<gt>" code. 512*0Sstevel@tonic-gate 513*0Sstevel@tonic-gate=for comment 514*0Sstevel@tonic-gate This was formerly explained as a "zero-width character". But it in 515*0Sstevel@tonic-gate most parser models, it parses to nothing at all, as opposed to parsing 516*0Sstevel@tonic-gate as if it were a E<zwnj> or E<zwj>, which are REAL zero-width characters. 517*0Sstevel@tonic-gate So "width" and "character" are exactly the wrong words. 518*0Sstevel@tonic-gate 519*0Sstevel@tonic-gate=back 520*0Sstevel@tonic-gate 521*0Sstevel@tonic-gateMost of the time, you will need only a single set of angle brackets to 522*0Sstevel@tonic-gatedelimit the beginning and end of formatting codes. However, 523*0Sstevel@tonic-gatesometimes you will want to put a real right angle bracket (a 524*0Sstevel@tonic-gategreater-than sign, '>') inside of a formatting code. This is particularly 525*0Sstevel@tonic-gatecommon when using a formatting code to provide a different font-type for a 526*0Sstevel@tonic-gatesnippet of code. As with all things in Perl, there is more than 527*0Sstevel@tonic-gateone way to do it. One way is to simply escape the closing bracket 528*0Sstevel@tonic-gateusing an C<E> code: 529*0Sstevel@tonic-gate 530*0Sstevel@tonic-gate C<$a E<lt>=E<gt> $b> 531*0Sstevel@tonic-gate 532*0Sstevel@tonic-gateThis will produce: "C<$a E<lt>=E<gt> $b>" 533*0Sstevel@tonic-gate 534*0Sstevel@tonic-gateA more readable, and perhaps more "plain" way is to use an alternate 535*0Sstevel@tonic-gateset of delimiters that doesn't require a single ">" to be escaped. With 536*0Sstevel@tonic-gatethe Pod formatters that are standard starting with perl5.5.660, doubled 537*0Sstevel@tonic-gateangle brackets ("<<" and ">>") may be used I<if and only if there is 538*0Sstevel@tonic-gatewhitespace right after the opening delimiter and whitespace right 539*0Sstevel@tonic-gatebefore the closing delimiter!> For example, the following will 540*0Sstevel@tonic-gatedo the trick: 541*0Sstevel@tonic-gate 542*0Sstevel@tonic-gate C<< $a <=> $b >> 543*0Sstevel@tonic-gate 544*0Sstevel@tonic-gateIn fact, you can use as many repeated angle-brackets as you like so 545*0Sstevel@tonic-gatelong as you have the same number of them in the opening and closing 546*0Sstevel@tonic-gatedelimiters, and make sure that whitespace immediately follows the last 547*0Sstevel@tonic-gate'<' of the opening delimiter, and immediately precedes the first '>' 548*0Sstevel@tonic-gateof the closing delimiter. (The whitespace is ignored.) So the 549*0Sstevel@tonic-gatefollowing will also work: 550*0Sstevel@tonic-gate 551*0Sstevel@tonic-gate C<<< $a <=> $b >>> 552*0Sstevel@tonic-gate C<<<< $a <=> $b >>>> 553*0Sstevel@tonic-gate 554*0Sstevel@tonic-gateAnd they all mean exactly the same as this: 555*0Sstevel@tonic-gate 556*0Sstevel@tonic-gate C<$a E<lt>=E<gt> $b> 557*0Sstevel@tonic-gate 558*0Sstevel@tonic-gateAs a further example, this means that if you wanted to put these bits of 559*0Sstevel@tonic-gatecode in C<C> (code) style: 560*0Sstevel@tonic-gate 561*0Sstevel@tonic-gate open(X, ">>thing.dat") || die $! 562*0Sstevel@tonic-gate $foo->bar(); 563*0Sstevel@tonic-gate 564*0Sstevel@tonic-gateyou could do it like so: 565*0Sstevel@tonic-gate 566*0Sstevel@tonic-gate C<<< open(X, ">>thing.dat") || die $! >>> 567*0Sstevel@tonic-gate C<< $foo->bar(); >> 568*0Sstevel@tonic-gate 569*0Sstevel@tonic-gatewhich is presumably easier to read than the old way: 570*0Sstevel@tonic-gate 571*0Sstevel@tonic-gate C<open(X, "E<gt>E<gt>thing.dat") || die $!> 572*0Sstevel@tonic-gate C<$foo-E<gt>bar();> 573*0Sstevel@tonic-gate 574*0Sstevel@tonic-gateThis is currently supported by pod2text (Pod::Text), pod2man (Pod::Man), 575*0Sstevel@tonic-gateand any other pod2xxx or Pod::Xxxx translators that use 576*0Sstevel@tonic-gatePod::Parser 1.093 or later, or Pod::Tree 1.02 or later. 577*0Sstevel@tonic-gate 578*0Sstevel@tonic-gate=head2 The Intent 579*0Sstevel@tonic-gate 580*0Sstevel@tonic-gateThe intent is simplicity of use, not power of expression. Paragraphs 581*0Sstevel@tonic-gatelook like paragraphs (block format), so that they stand out 582*0Sstevel@tonic-gatevisually, and so that I could run them through C<fmt> easily to reformat 583*0Sstevel@tonic-gatethem (that's F7 in my version of B<vi>, or Esc Q in my version of 584*0Sstevel@tonic-gateB<emacs>). I wanted the translator to always leave the C<'> and C<`> and 585*0Sstevel@tonic-gateC<"> quotes alone, in verbatim mode, so I could slurp in a 586*0Sstevel@tonic-gateworking program, shift it over four spaces, and have it print out, er, 587*0Sstevel@tonic-gateverbatim. And presumably in a monospace font. 588*0Sstevel@tonic-gate 589*0Sstevel@tonic-gateThe Pod format is not necessarily sufficient for writing a book. Pod 590*0Sstevel@tonic-gateis just meant to be an idiot-proof common source for nroff, HTML, 591*0Sstevel@tonic-gateTeX, and other markup languages, as used for online 592*0Sstevel@tonic-gatedocumentation. Translators exist for B<pod2text>, B<pod2html>, 593*0Sstevel@tonic-gateB<pod2man> (that's for nroff(1) and troff(1)), B<pod2latex>, and 594*0Sstevel@tonic-gateB<pod2fm>. Various others are available in CPAN. 595*0Sstevel@tonic-gate 596*0Sstevel@tonic-gate 597*0Sstevel@tonic-gate=head2 Embedding Pods in Perl Modules 598*0Sstevel@tonic-gate 599*0Sstevel@tonic-gateYou can embed Pod documentation in your Perl modules and scripts. 600*0Sstevel@tonic-gateStart your documentation with an empty line, a "=head1" command at the 601*0Sstevel@tonic-gatebeginning, and end it with a "=cut" command and an empty line. Perl 602*0Sstevel@tonic-gatewill ignore the Pod text. See any of the supplied library modules for 603*0Sstevel@tonic-gateexamples. If you're going to put your Pod at the end of the file, and 604*0Sstevel@tonic-gateyou're using an __END__ or __DATA__ cut mark, make sure to put an 605*0Sstevel@tonic-gateempty line there before the first Pod command. 606*0Sstevel@tonic-gate 607*0Sstevel@tonic-gate __END__ 608*0Sstevel@tonic-gate 609*0Sstevel@tonic-gate =head1 NAME 610*0Sstevel@tonic-gate 611*0Sstevel@tonic-gate Time::Local - efficiently compute time from local and GMT time 612*0Sstevel@tonic-gate 613*0Sstevel@tonic-gateWithout that empty line before the "=head1", many translators wouldn't 614*0Sstevel@tonic-gatehave recognized the "=head1" as starting a Pod block. 615*0Sstevel@tonic-gate 616*0Sstevel@tonic-gate=head2 Hints for Writing Pod 617*0Sstevel@tonic-gate 618*0Sstevel@tonic-gate=over 619*0Sstevel@tonic-gate 620*0Sstevel@tonic-gate=item * 621*0Sstevel@tonic-gate 622*0Sstevel@tonic-gateThe B<podchecker> command is provided for checking Pod syntax for errors 623*0Sstevel@tonic-gateand warnings. For example, it checks for completely blank lines in 624*0Sstevel@tonic-gatePod blocks and for unknown commands and formatting codes. You should 625*0Sstevel@tonic-gatestill also pass your document through one or more translators and proofread 626*0Sstevel@tonic-gatethe result, or print out the result and proofread that. Some of the 627*0Sstevel@tonic-gateproblems found may be bugs in the translators, which you may or may not 628*0Sstevel@tonic-gatewish to work around. 629*0Sstevel@tonic-gate 630*0Sstevel@tonic-gate=item * 631*0Sstevel@tonic-gate 632*0Sstevel@tonic-gateIf you're more familiar with writing in HTML than with writing in Pod, you 633*0Sstevel@tonic-gatecan try your hand at writing documentation in simple HTML, and converting 634*0Sstevel@tonic-gateit to Pod with the experimental L<Pod::HTML2Pod|Pod::HTML2Pod> module, 635*0Sstevel@tonic-gate(available in CPAN), and looking at the resulting code. The experimental 636*0Sstevel@tonic-gateL<Pod::PXML|Pod::PXML> module in CPAN might also be useful. 637*0Sstevel@tonic-gate 638*0Sstevel@tonic-gate=item * 639*0Sstevel@tonic-gate 640*0Sstevel@tonic-gateMany older Pod translators require the lines before every Pod 641*0Sstevel@tonic-gatecommand and after every Pod command (including "=cut"!) to be a blank 642*0Sstevel@tonic-gateline. Having something like this: 643*0Sstevel@tonic-gate 644*0Sstevel@tonic-gate # - - - - - - - - - - - - 645*0Sstevel@tonic-gate =item $firecracker->boom() 646*0Sstevel@tonic-gate 647*0Sstevel@tonic-gate This noisily detonates the firecracker object. 648*0Sstevel@tonic-gate =cut 649*0Sstevel@tonic-gate sub boom { 650*0Sstevel@tonic-gate ... 651*0Sstevel@tonic-gate 652*0Sstevel@tonic-gate...will make such Pod translators completely fail to see the Pod block 653*0Sstevel@tonic-gateat all. 654*0Sstevel@tonic-gate 655*0Sstevel@tonic-gateInstead, have it like this: 656*0Sstevel@tonic-gate 657*0Sstevel@tonic-gate # - - - - - - - - - - - - 658*0Sstevel@tonic-gate 659*0Sstevel@tonic-gate =item $firecracker->boom() 660*0Sstevel@tonic-gate 661*0Sstevel@tonic-gate This noisily detonates the firecracker object. 662*0Sstevel@tonic-gate 663*0Sstevel@tonic-gate =cut 664*0Sstevel@tonic-gate 665*0Sstevel@tonic-gate sub boom { 666*0Sstevel@tonic-gate ... 667*0Sstevel@tonic-gate 668*0Sstevel@tonic-gate=item * 669*0Sstevel@tonic-gate 670*0Sstevel@tonic-gateSome older Pod translators require paragraphs (including command 671*0Sstevel@tonic-gateparagraphs like "=head2 Functions") to be separated by I<completely> 672*0Sstevel@tonic-gateempty lines. If you have an apparently empty line with some spaces 673*0Sstevel@tonic-gateon it, this might not count as a separator for those translators, and 674*0Sstevel@tonic-gatethat could cause odd formatting. 675*0Sstevel@tonic-gate 676*0Sstevel@tonic-gate=item * 677*0Sstevel@tonic-gate 678*0Sstevel@tonic-gateOlder translators might add wording around an LE<lt>E<gt> link, so that 679*0Sstevel@tonic-gateC<LE<lt>Foo::BarE<gt>> may become "the Foo::Bar manpage", for example. 680*0Sstevel@tonic-gateSo you shouldn't write things like C<the LE<lt>fooE<gt> 681*0Sstevel@tonic-gatedocumentation>, if you want the translated document to read sensibly 682*0Sstevel@tonic-gate-- instead write C<the LE<lt>Foo::Bar|Foo::BarE<gt> documentation> or 683*0Sstevel@tonic-gateC<LE<lt>the Foo::Bar documentation|Foo::BarE<gt>>, to control how the 684*0Sstevel@tonic-gatelink comes out. 685*0Sstevel@tonic-gate 686*0Sstevel@tonic-gate=item * 687*0Sstevel@tonic-gate 688*0Sstevel@tonic-gateGoing past the 70th column in a verbatim block might be ungracefully 689*0Sstevel@tonic-gatewrapped by some formatters. 690*0Sstevel@tonic-gate 691*0Sstevel@tonic-gate=back 692*0Sstevel@tonic-gate 693*0Sstevel@tonic-gate=head1 SEE ALSO 694*0Sstevel@tonic-gate 695*0Sstevel@tonic-gateL<perlpodspec>, L<perlsyn/"PODs: Embedded Documentation">, 696*0Sstevel@tonic-gateL<perlnewmod>, L<perldoc>, L<pod2html>, L<pod2man>, L<podchecker>. 697*0Sstevel@tonic-gate 698*0Sstevel@tonic-gate=head1 AUTHOR 699*0Sstevel@tonic-gate 700*0Sstevel@tonic-gateLarry Wall, Sean M. Burke 701*0Sstevel@tonic-gate 702*0Sstevel@tonic-gate=cut 703