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

📄 perlform.pod

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 POD
📖 第 1 页 / 共 2 页
字号:
 . format STDOUT = @<<<<<<<<<<<<<<<<<< @||||||| @<<<<<<@>>>> @>>>> @<<<<<<<<<<<<<<<<< $name,              $login,  $office,$uid,$gid, $home . # a report from a bug report form format STDOUT_TOP =                         Bug Reports @<<<<<<<<<<<<<<<<<<<<<<<     @|||         @>>>>>>>>>>>>>>>>>>>>>>> $system,                      $%,         $date ------------------------------------------------------------------ . format STDOUT = Subject: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<          $subject Index: @<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<        $index,                       $description Priority: @<<<<<<<<<< Date: @<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<           $priority,        $date,   $description From: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<       $from,                         $description Assigned to: @<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<              $programmer,            $description ~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<                                      $description ~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<                                      $description ~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<                                      $description ~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<                                      $description ~                                    ^<<<<<<<<<<<<<<<<<<<<<<<...                                      $description .It is possible to intermix print()s with write()s on the same outputchannel, but you'll have to handle C<$-> (C<$FORMAT_LINES_LEFT>)yourself.=head2 Format VariablesX<format variables>X<format, variables>The current format name is stored in the variable C<$~> (C<$FORMAT_NAME>),and the current top of form format name is in C<$^> (C<$FORMAT_TOP_NAME>).The current output page number is stored in C<$%> (C<$FORMAT_PAGE_NUMBER>),and the number of lines on the page is in C<$=> (C<$FORMAT_LINES_PER_PAGE>).Whether to autoflush output on this handle is stored in C<$|>(C<$OUTPUT_AUTOFLUSH>).  The string output before each top of page (exceptthe first) is stored in C<$^L> (C<$FORMAT_FORMFEED>).  These variables areset on a per-filehandle basis, so you'll need to select() into a differentone to affect them:    select((select(OUTF),	    $~ = "My_Other_Format",	    $^ = "My_Top_Format"	   )[0]);Pretty ugly, eh?  It's a common idiom though, so don't be too surprisedwhen you see it.  You can at least use a temporary variable to holdthe previous filehandle: (this is a much better approach in general,because not only does legibility improve, you now have intermediarystage in the expression to single-step the debugger through):    $ofh = select(OUTF);    $~ = "My_Other_Format";    $^ = "My_Top_Format";    select($ofh);If you use the English module, you can even read the variable names:    use English '-no_match_vars';    $ofh = select(OUTF);    $FORMAT_NAME     = "My_Other_Format";    $FORMAT_TOP_NAME = "My_Top_Format";    select($ofh);But you still have those funny select()s.  So just use the FileHandlemodule.  Now, you can access these special variables using lowercasemethod names instead:    use FileHandle;    format_name     OUTF "My_Other_Format";    format_top_name OUTF "My_Top_Format";Much better!=head1 NOTESBecause the values line may contain arbitrary expressions (for at fields,not caret fields), you can farm out more sophisticated processingto other functions, like sprintf() or one of your own.  For example:    format Ident =	@<<<<<<<<<<<<<<<	&commify($n)    .To get a real at or caret into the field, do this:    format Ident =    I have an @ here.	    "@"    .To center a whole line of text, do something like this:    format Ident =    @|||||||||||||||||||||||||||||||||||||||||||||||	    "Some text line"    .There is no builtin way to say "float this to the right hand sideof the page, however wide it is."  You have to specify where it goes.The truly desperate can generate their own format on the fly, basedon the current number of columns, and then eval() it:    $format  = "format STDOUT = \n"             . '^' . '<' x $cols . "\n"             . '$entry' . "\n"             . "\t^" . "<" x ($cols-8) . "~~\n"             . '$entry' . "\n"             . ".\n";    print $format if $Debugging;    eval $format;    die $@ if $@;Which would generate a format looking something like this: format STDOUT = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $entry         ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $entry .Here's a little program that's somewhat like fmt(1): format = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~ $_ . $/ = ''; while (<>) {     s/\s*\n\s*/ /g;     write; }=head2 FootersX<format, footer> X<footer>While $FORMAT_TOP_NAME contains the name of the current header format,there is no corresponding mechanism to automatically do the same thingfor a footer.  Not knowing how big a format is going to be until youevaluate it is one of the major problems.  It's on the TODO list.Here's one strategy:  If you have a fixed-size footer, you can get footersby checking $FORMAT_LINES_LEFT before each write() and print the footeryourself if necessary.Here's another strategy: Open a pipe to yourself, using C<open(MYSELF, "|-")>(see L<perlfunc/open()>) and always write() to MYSELF instead of STDOUT.Have your child process massage its STDIN to rearrange headers and footershowever you like.  Not very convenient, but doable.=head2 Accessing Formatting InternalsX<format, internals>For low-level access to the formatting mechanism.  you may use formline()and access C<$^A> (the $ACCUMULATOR variable) directly.For example:    $str = formline <<'END', 1,2,3;    @<<<  @|||  @>>>    END    print "Wow, I just stored `$^A' in the accumulator!\n";Or to make an swrite() subroutine, which is to write() what sprintf()is to printf(), do this:    use Carp;    sub swrite {	croak "usage: swrite PICTURE ARGS" unless @_;	my $format = shift;	$^A = "";	formline($format,@_);	return $^A;    }    $string = swrite(<<'END', 1, 2, 3); Check me out @<<<  @|||  @>>> END    print $string;=head1 WARNINGSThe lone dot that ends a format can also prematurely end a mailmessage passing through a misconfigured Internet mailer (and based onexperience, such misconfiguration is the rule, not the exception).  Sowhen sending format code through mail, you should indent it so thatthe format-ending dot is not on the left margin; this will preventSMTP cutoff.Lexical variables (declared with "my") are not visible within aformat unless the format is declared within the scope of the lexicalvariable.  (They weren't visible at all before version 5.001.)Formats are the only part of Perl that unconditionally use informationfrom a program's locale; if a program's environment specifies anLC_NUMERIC locale, it is always used to specify the decimal pointcharacter in formatted output.  Perl ignores all other aspects of localehandling unless the C<use locale> pragma is in effect.  Formatted outputcannot be controlled by C<use locale> because the pragma is tied to theblock structure of the program, and, for historical reasons, formatsexist outside that block structure.  See L<perllocale> for furtherdiscussion of locale handling.Within strings that are to be displayed in a fixed length text field,each control character is substituted by a space. (But remember thespecial meaning of C<\r> when using fill mode.) This is done to avoidmisalignment when control characters "disappear" on some output media.

⌨️ 快捷键说明

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