⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perlform.pod

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 POD
📖 第 1 页 / 共 2 页
字号:
=head1 NAMEX<format> X<report> X<chart>perlform - Perl formats=head1 DESCRIPTIONPerl 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 FORTRAN: format() to declare and write()to execute; see their entries in L<perlfunc>.  Fortunately, the layout ismuch more legible, more like BASIC's PRINT USING statement.  Think of itas a poor man's nroff(1).X<nroff>Formats, 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 "types" in Perl.  This means that if you have afunction named "Foo", it is not the same thing as having a format named"Foo".  However, the default name for the format associated with a givenfilehandle is the same as the name of the filehandle.  Thus, the defaultformat for STDOUT is named "STDOUT", and the default format for filehandleTEMP is named "TEMP".  They just look the same.  They aren't.Output record formats are declared as follows:    format NAME =    FORMLIST    .If the name is omitted, format "STDOUT" is defined. A single "." in column 1 is used to terminate a format.  FORMLIST consists of a sequence of lines, each of which may be one of three types:=over 4=item 1.A comment, indicated by putting a '#' in the first column.=item 2.A "picture" line giving the format for one output line.=item 3.An argument line supplying values to plug into the previous picture line.=backPicture 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:X<format, picture line>X<@> X<^> X<< < >> X<< | >> X<< > >> X<#> X<0> X<.> X<...>X<@*> X<^*> X<~> X<~~>     @    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 exhaustedEach field in a picture line starts with either "@" (at) or "^" (caret),indicating what we'll call, respectively, a "regular" or "special" 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.=head2 Text FieldsX<format, text field>The length of the field is supplied by padding out the field with multiple "E<lt>", "E<gt>", or "|" 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 "...", 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> for details.   Example:      format STDOUT =      @<<<<<<   @||||||   @>>>>>>      "left",   "middle", "right"      .   Output:      left      middle    right=head2 Numeric FieldsX<#> X<format, numeric field>Using "#" as a padding character specifies a numeric field, withright justification. An optional "." defines the position of thedecimal point. With a "0" (zero) instead of the first "#", 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 "#" as overflow evidence.   Example:      format STDOUT =      @###   @.###   @##.###  @###   @###   ^####       42,   3.1415,  undef,    0, 10000,   undef      .   Output:        42   3.142     0.000     0   ####=head2 The Field @* for Variable Width Multi-Line TextX<@*>The field "@*" 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.=head2 The Field ^* for Variable Width One-line-at-a-time TextX<^*>Like "@*", this is a variable width field. The value supplied must be a scalar variable. Perl puts the first line (up to the first "\n") 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 I<not> be restored.   Example:      $text = "line 1\nline 2\nline 3";      format STDOUT =      Text: ^*            $text      ~~    ^*            $text      .   Output:      Text: line 1            line 2            line 3=head2 Specifying ValuesX<format, 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 "#"characters B<without> an embedded "."), the character used for the decimalpoint is B<always> determined by the current LC_NUMERIC locale.  Thismeans that, if, for example, the run-time environment happens to specify aGerman locale, "," will be used instead of the default ".".  SeeL<perllocale> and L<"WARNINGS"> for more information.=head2 Using Fill ModeX<format, fill mode>On text fields the caret enables a kind of fill mode.  Instead of anarbitrary expression, the value supplied must be a scalar variablethat contains a text string.  Perl puts the next portion of the text intothe field, and then chops off the front of the string so that the next timethe variable is referenced, more of the text can be printed.  (Yes, thismeans that the variable itself is altered during execution of the write()call, and is not restored.)  The next portion of text is determined bya crude line breaking algorithm. You may use the carriage return character(C<\r>) to force a line break. You can change which characters are legal to break on by changing the variable C<$:> (that's $FORMAT_LINE_BREAK_CHARACTERS if you're using the English module) to a list of the desired characters.Normally you would use a sequence of fields in a vertical stack associated with the same scalar variable to print out a block of text. You might wish to end the final field with the text "...", which will appear in the output if the text was too long to appear in its entirety.  =head2 Suppressing Lines Where All Fields Are VoidX<format, suppressing lines>Using caret fields can produce lines where all fields are blank. You cansuppress such lines by putting a "~" (tilde) character anywhere in theline.  The tilde will be translated to a space upon output.=head2 Repeating Format LinesX<format, repeating lines>If you put two contiguous tilde characters "~~" anywhere into a line,the line will be repeated until all the fields on the line are exhausted,i.e. undefined. For special (caret) text fields this will occur sooner orlater, but if you use a text field of the at variety, the  expression yousupply had better not give the same value every time forever! (C<shift(@f)>is a simple example that would work.)  Don't use a regular (at) numeric field in such lines, because it will never go blank.=head2 Top of Form ProcessingX<format, top of form> X<top> X<header>Top-of-form processing is by default handled by a format with thesame name as the current filehandle with "_TOP" concatenated to it.It's triggered at the top of each page.  See L<perlfunc/write>.Examples: # a report on the /etc/passwd file format STDOUT_TOP =                         Passwd File Name                Login    Office   Uid   Gid Home ------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -