📄 perlform.1
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "PERLFORM 1".TH PERLFORM 1 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"perlform \- Perl formats.IX Xref "format report chart".SH "DESCRIPTION".IX Header "DESCRIPTION"Perl has a mechanism to help you generate simple reports and charts. Tofacilitate this, Perl helps you code up your output page close to how itwill look when it's printed. It can keep track of things like how manylines are on a page, what page you're on, when to print page headers,etc. Keywords are borrowed from \s-1FORTRAN:\s0 \fIformat()\fR to declare and \fIwrite()\fRto execute; see their entries in perlfunc. Fortunately, the layout ismuch more legible, more like \s-1BASIC\s0's \s-1PRINT\s0 \s-1USING\s0 statement. Think of itas a poor man's \fInroff\fR\|(1)..IX Xref "nroff".PPFormats, like packages and subroutines, are declared rather thanexecuted, so they may occur at any point in your program. (Usually it'sbest to keep them all together though.) They have their own namespaceapart from all the other \*(L"types\*(R" in Perl. This means that if you have afunction named \*(L"Foo\*(R", it is not the same thing as having a format named\&\*(L"Foo\*(R". However, the default name for the format associated with a givenfilehandle is the same as the name of the filehandle. Thus, the defaultformat for \s-1STDOUT\s0 is named \*(L"\s-1STDOUT\s0\*(R", and the default format for filehandle\&\s-1TEMP\s0 is named \*(L"\s-1TEMP\s0\*(R". They just look the same. They aren't..PPOutput record formats are declared as follows:.PP.Vb 3\& format NAME =\& FORMLIST\& ..Ve.PPIf the name is omitted, format \*(L"\s-1STDOUT\s0\*(R" is defined. A single \*(L".\*(R" in column 1 is used to terminate a format. \s-1FORMLIST\s0 consists of a sequence of lines, each of which may be one of three types:.IP "1." 4A comment, indicated by putting a '#' in the first column..IP "2." 4A \*(L"picture\*(R" line giving the format for one output line..IP "3." 4An argument line supplying values to plug into the previous picture line..PPPicture lines contain output field definitions, intermingled withliteral text. These lines do not undergo any kind of variable interpolation.Field definitions are made up from a set of characters, for starting andextending a field to its desired width. This is the complete set ofcharacters for field definitions:.IX Xref "format, picture line @ ^ < | > # 0 . ... @* ^* ~ ~~".PP.Vb 10\& @ start of regular field\& ^ start of special field\& < pad character for left adjustification\& | pad character for centering\& > pad character for right adjustificat\& # pad character for a right justified numeric field\& 0 instead of first #: pad number with leading zeroes\& . decimal point within a numeric field\& ... terminate a text field, show "..." as truncation evidence\& @* variable width field for a multi\-line value\& ^* variable width field for next line of a multi\-line value\& ~ suppress line with all fields empty\& ~~ repeat line until all fields are exhausted.Ve.PPEach field in a picture line starts with either \*(L"@\*(R" (at) or \*(L"^\*(R" (caret),indicating what we'll call, respectively, a \*(L"regular\*(R" or \*(L"special\*(R" field.The choice of pad characters determines whether a field is textual ornumeric. The tilde operators are not part of a field. Let's look atthe various possibilities in detail..Sh "Text Fields".IX Xref "format, text field".IX Subsection "Text Fields"The length of the field is supplied by padding out the field with multiple \&\*(L"<\*(R", \*(L">\*(R", or \*(L"|\*(R" characters to specify a non-numeric field with,respectively, left justification, right justification, or centering. For a regular field, the value (up to the first newline) is taken andprinted according to the selected justification, truncating excess characters.If you terminate a text field with \*(L"...\*(R", three dots will be shown ifthe value is truncated. A special text field may be used to do rudimentary multi-line text block filling; see \*(L"Using Fill Mode\*(R" for details..PP.Vb 7\& Example:\& format STDOUT =\& @<<<<<< @|||||| @>>>>>>\& "left", "middle", "right"\& .\& Output:\& left middle right.Ve.Sh "Numeric Fields".IX Xref "# format, numeric field".IX Subsection "Numeric Fields"Using \*(L"#\*(R" as a padding character specifies a numeric field, withright justification. An optional \*(L".\*(R" defines the position of thedecimal point. With a \*(L"0\*(R" (zero) instead of the first \*(L"#\*(R", theformatted number will be padded with leading zeroes if necessary.A special numeric field is blanked out if the value is undefined.If the resulting value would exceed the width specified the field isfilled with \*(L"#\*(R" as overflow evidence..PP.Vb 7\& Example:\& format STDOUT =\& @### @.### @##.### @### @### ^####\& 42, 3.1415, undef, 0, 10000, undef\& .\& Output:\& 42 3.142 0.000 0 ####.Ve.Sh "The Field @* for Variable Width Multi-Line Text".IX Xref "@*".IX Subsection "The Field @* for Variable Width Multi-Line Text"The field \*(L"@*\*(R" can be used for printing multi-line, nontruncatedvalues; it should (but need not) appear by itself on a line. A finalline feed is chomped off, but all other characters are emitted verbatim..Sh "The Field ^* for Variable Width One-line-at-a-time Text".IX Xref "^*".IX Subsection "The Field ^* for Variable Width One-line-at-a-time Text"Like \*(L"@*\*(R", this is a variable width field. The value supplied must be a scalar variable. Perl puts the first line (up to the first \*(L"\en\*(R") of the text into the field, and then chops off the front of the string so that the next time the variable is referenced, more of the text can be printed. The variable will \fInot\fR be restored..PP.Vb 12\& Example:\& $text = "line 1\enline 2\enline 3";\& format STDOUT =\& Text: ^*\& $text\& ~~ ^*\& $text\& .\& Output:\& Text: line 1\& line 2\& line 3.Ve.Sh "Specifying Values".IX Xref "format, specifying values".IX Subsection "Specifying Values"The values are specified on the following format line in the same order asthe picture fields. The expressions providing the values must beseparated by commas. They are all evaluated in a list contextbefore the line is processed, so a single list expression could producemultiple list elements. The expressions may be spread out to more thanone line if enclosed in braces. If so, the opening brace must be the firsttoken on the first line. If an expression evaluates to a number with adecimal part, and if the corresponding picture specifies that the decimalpart should appear in the output (that is, any picture except multiple \*(L"#\*(R"characters \fBwithout\fR an embedded \*(L".\*(R"), the character used for the decimalpoint is \fBalways\fR determined by the current \s-1LC_NUMERIC\s0 locale. Thismeans that, if, for example, the run-time environment happens to specify aGerman locale, \*(L",\*(R" will be used instead of the default \*(L".\*(R". Seeperllocale and \*(L"\s-1WARNINGS\s0\*(R" for more information..Sh "Using Fill Mode"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -