X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlform.pod;h=b2c87fa9b0753189e5a56022359a4c1ae77c77d0;hb=b988f96b4d2a582eb175809bd8070316bbc37118;hp=7e540b8ff69b9a63c6aa399fffb712ac99566e0d;hpb=4a6725af9146bd7faaa10aa5429ff009d393fd6d;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlform.pod b/pod/perlform.pod index 7e540b8..b2c87fa 100644 --- a/pod/perlform.pod +++ b/pod/perlform.pod @@ -20,8 +20,8 @@ apart from all the other "types" in Perl. This means that if you have a function named "Foo", it is not the same thing as having a format named "Foo". However, the default name for the format associated with a given filehandle is the same as the name of the filehandle. Thus, the default -format for STDOUT is name "STDOUT", and the default format for filehandle -TEMP is name "TEMP". They just look the same. They aren't. +format for STDOUT is named "STDOUT", and the default format for filehandle +TEMP is named "TEMP". They just look the same. They aren't. Output record formats are declared as follows: @@ -233,11 +233,11 @@ of the page, however wide it is." You have to specify where it goes. The truly desperate can generate their own format on the fly, based on 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"; + $format = "format STDOUT = \n" + . '^' . '<' x $cols . "\n" + . '$entry' . "\n" + . "\t^" . "<" x ($cols-8) . "~~\n" + . '$entry' . "\n" . ".\n"; print $format if $Debugging; eval $format; @@ -295,7 +295,7 @@ For example: print "Wow, I just stored `$^A' in the accumulator!\n"; -Or to make an swrite() subroutine which is to write() what sprintf() +Or to make an swrite() subroutine, which is to write() what sprintf() is to printf(), do this: use Carp; @@ -315,18 +315,18 @@ is to printf(), do this: =head1 WARNINGS -The lone dot that ends a format can also prematurely end an email +The lone dot that ends a format can also prematurely end a mail message passing through a misconfigured Internet mailer (and based on experience, such misconfiguration is the rule, not the exception). So -when sending format code through email, you should indent it so that +when sending format code through mail, you should indent it so that the format-ending dot is not on the left margin; this will prevent -email cutoff. +SMTP cutoff. Lexical variables (declared with "my") are not visible within a format unless the format is declared within the scope of the lexical variable. (They weren't visible at all before version 5.001.) -Formats are the only part of Perl which unconditionally use information +Formats are the only part of Perl that unconditionally use information from a program's locale; if a program's environment specifies an LC_NUMERIC locale, it is always used to specify the decimal point character in formatted output. Perl ignores all other aspects of locale @@ -335,3 +335,12 @@ cannot be controlled by C because the pragma is tied to the block structure of the program, and, for historical reasons, formats exist outside that block structure. See L for further discussion of locale handling. + +Inside of an expression, the whitespace characters \n, \t and \f are +considered to be equivalent to a single space. Thus, you could think +of this filter being applied to each value in the format: + + $value =~ tr/\n\t\f/ /; + +The remaining whitespace character, \r, forces the printing of a new +line if allowed by the picture line.