Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / man / man1 / perlform.1
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "PERLFORM 1"
132.TH PERLFORM 1 "2006-01-07" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134.IX Xref "format report chart"
135perlform \- Perl formats
136.SH "DESCRIPTION"
137.IX Header "DESCRIPTION"
138Perl has a mechanism to help you generate simple reports and charts. To
139facilitate this, Perl helps you code up your output page close to how it
140will look when it's printed. It can keep track of things like how many
141lines are on a page, what page you're on, when to print page headers,
142etc. Keywords are borrowed from \s-1FORTRAN:\s0 \fIformat()\fR to declare and \fIwrite()\fR
143to execute; see their entries in perlfunc. Fortunately, the layout is
144much more legible, more like \s-1BASIC\s0's \s-1PRINT\s0 \s-1USING\s0 statement. Think of it
145as a poor man's \fInroff\fR\|(1).
146.IX Xref "nroff"
147.PP
148Formats, like packages and subroutines, are declared rather than
149executed, so they may occur at any point in your program. (Usually it's
150best to keep them all together though.) They have their own namespace
151apart from all the other \*(L"types\*(R" in Perl. This means that if you have a
152function named \*(L"Foo\*(R", it is not the same thing as having a format named
153\&\*(L"Foo\*(R". However, the default name for the format associated with a given
154filehandle is the same as the name of the filehandle. Thus, the default
155format for \s-1STDOUT\s0 is named \*(L"\s-1STDOUT\s0\*(R", and the default format for filehandle
156\&\s-1TEMP\s0 is named \*(L"\s-1TEMP\s0\*(R". They just look the same. They aren't.
157.PP
158Output record formats are declared as follows:
159.PP
160.Vb 3
161\& format NAME =
162\& FORMLIST
163\& .
164.Ve
165.PP
166If the name is omitted, format \*(L"\s-1STDOUT\s0\*(R" is defined. A single \*(L".\*(R" in
167column 1 is used to terminate a format. \s-1FORMLIST\s0 consists of a sequence
168of lines, each of which may be one of three types:
169.IP "1." 4
170A comment, indicated by putting a '#' in the first column.
171.IP "2." 4
172A \*(L"picture\*(R" line giving the format for one output line.
173.IP "3." 4
174An argument line supplying values to plug into the previous picture line.
175.PP
176Picture lines contain output field definitions, intermingled with
177literal text. These lines do not undergo any kind of variable interpolation.
178Field definitions are made up from a set of characters, for starting and
179extending a field to its desired width. This is the complete set of
180characters for field definitions:
181.IX Xref "format, picture line @ ^ < | > # 0 . ... @* ^* ~ ~~"
182.PP
183.Vb 13
184\& @ start of regular field
185\& ^ start of special field
186\& < pad character for left adjustification
187\& | pad character for centering
188\& > pad character for right adjustificat
189\& # pad character for a right justified numeric field
190\& 0 instead of first #: pad number with leading zeroes
191\& . decimal point within a numeric field
192\& ... terminate a text field, show "..." as truncation evidence
193\& @* variable width field for a multi-line value
194\& ^* variable width field for next line of a multi-line value
195\& ~ suppress line with all fields empty
196\& ~~ repeat line until all fields are exhausted
197.Ve
198.PP
199Each field in a picture line starts with either \*(L"@\*(R" (at) or \*(L"^\*(R" (caret),
200indicating what we'll call, respectively, a \*(L"regular\*(R" or \*(L"special\*(R" field.
201The choice of pad characters determines whether a field is textual or
202numeric. The tilde operators are not part of a field. Let's look at
203the various possibilities in detail.
204.Sh "Text Fields"
205.IX Xref "format, text field"
206.IX Subsection "Text Fields"
207The length of the field is supplied by padding out the field with multiple
208"<\*(L", \*(R">\*(L", or \*(R"|\*(L" characters to specify a non-numeric field with,
209respectively, left justification, right justification, or centering.
210For a regular field, the value (up to the first newline) is taken and
211printed according to the selected justification, truncating excess characters.
212If you terminate a text field with \*(R"...", three dots will be shown if
213the value is truncated. A special text field may be used to do rudimentary
214multi-line text block filling; see \*(L"Using Fill Mode\*(R" for details.
215.PP
216.Vb 7
217\& Example:
218\& format STDOUT =
219\& @<<<<<< @|||||| @>>>>>>
220\& "left", "middle", "right"
221\& .
222\& Output:
223\& left middle right
224.Ve
225.Sh "Numeric Fields"
226.IX Xref "# format, numeric field"
227.IX Subsection "Numeric Fields"
228Using \*(L"#\*(R" as a padding character specifies a numeric field, with
229right justification. An optional \*(L".\*(R" defines the position of the
230decimal point. With a \*(L"0\*(R" (zero) instead of the first \*(L"#\*(R", the
231formatted number will be padded with leading zeroes if necessary.
232A special numeric field is blanked out if the value is undefined.
233If the resulting value would exceed the width specified the field is
234filled with \*(L"#\*(R" as overflow evidence.
235.PP
236.Vb 7
237\& Example:
238\& format STDOUT =
239\& @### @.### @##.### @### @### ^####
240\& 42, 3.1415, undef, 0, 10000, undef
241\& .
242\& Output:
243\& 42 3.142 0.000 0 ####
244.Ve
245.Sh "The Field @* for Variable Width Multi-Line Text"
246.IX Xref "@*"
247.IX Subsection "The Field @* for Variable Width Multi-Line Text"
248The field \*(L"@*\*(R" can be used for printing multi\-line, nontruncated
249values; it should (but need not) appear by itself on a line. A final
250line feed is chomped off, but all other characters are emitted verbatim.
251.Sh "The Field ^* for Variable Width One-line-at-a-time Text"
252.IX Xref "^*"
253.IX Subsection "The Field ^* for Variable Width One-line-at-a-time Text"
254Like \*(L"@*\*(R", this is a variable width field. The value supplied must be a
255scalar variable. Perl puts the first line (up to the first \*(L"\en\*(R") of the
256text into the field, and then chops off the front of the string so that
257the next time the variable is referenced, more of the text can be printed.
258The variable will \fInot\fR be restored.
259.PP
260.Vb 12
261\& Example:
262\& $text = "line 1\enline 2\enline 3";
263\& format STDOUT =
264\& Text: ^*
265\& $text
266\& ~~ ^*
267\& $text
268\& .
269\& Output:
270\& Text: line 1
271\& line 2
272\& line 3
273.Ve
274.Sh "Specifying Values"
275.IX Xref "format, specifying values"
276.IX Subsection "Specifying Values"
277The values are specified on the following format line in the same order as
278the picture fields. The expressions providing the values must be
279separated by commas. They are all evaluated in a list context
280before the line is processed, so a single list expression could produce
281multiple list elements. The expressions may be spread out to more than
282one line if enclosed in braces. If so, the opening brace must be the first
283token on the first line. If an expression evaluates to a number with a
284decimal part, and if the corresponding picture specifies that the decimal
285part should appear in the output (that is, any picture except multiple \*(L"#\*(R"
286characters \fBwithout\fR an embedded \*(L".\*(R"), the character used for the decimal
287point is \fBalways\fR determined by the current \s-1LC_NUMERIC\s0 locale. This
288means that, if, for example, the run-time environment happens to specify a
289German locale, \*(L",\*(R" will be used instead of the default \*(L".\*(R". See
290perllocale and \*(L"\s-1WARNINGS\s0\*(R" for more information.
291.Sh "Using Fill Mode"
292.IX Xref "format, fill mode"
293.IX Subsection "Using Fill Mode"
294On text fields the caret enables a kind of fill mode. Instead of an
295arbitrary expression, the value supplied must be a scalar variable
296that contains a text string. Perl puts the next portion of the text into
297the field, and then chops off the front of the string so that the next time
298the variable is referenced, more of the text can be printed. (Yes, this
299means that the variable itself is altered during execution of the \fIwrite()\fR
300call, and is not restored.) The next portion of text is determined by
301a crude line breaking algorithm. You may use the carriage return character
302(\f(CW\*(C`\er\*(C'\fR) to force a line break. You can change which characters are legal
303to break on by changing the variable \f(CW$:\fR (that's
304\&\f(CW$FORMAT_LINE_BREAK_CHARACTERS\fR if you're using the English module) to a
305list of the desired characters.
306.PP
307Normally you would use a sequence of fields in a vertical stack associated
308with the same scalar variable to print out a block of text. You might wish
309to end the final field with the text \*(L"...\*(R", which will appear in the output
310if the text was too long to appear in its entirety.
311.Sh "Suppressing Lines Where All Fields Are Void"
312.IX Xref "format, suppressing lines"
313.IX Subsection "Suppressing Lines Where All Fields Are Void"
314Using caret fields can produce lines where all fields are blank. You can
315suppress such lines by putting a \*(L"~\*(R" (tilde) character anywhere in the
316line. The tilde will be translated to a space upon output.
317.Sh "Repeating Format Lines"
318.IX Xref "format, repeating lines"
319.IX Subsection "Repeating Format Lines"
320If you put two contiguous tilde characters \*(L"~~\*(R" anywhere into a line,
321the line will be repeated until all the fields on the line are exhausted,
322i.e. undefined. For special (caret) text fields this will occur sooner or
323later, but if you use a text field of the at variety, the expression you
324supply had better not give the same value every time forever! (\f(CW\*(C`shift(@f)\*(C'\fR
325is a simple example that would work.) Don't use a regular (at) numeric
326field in such lines, because it will never go blank.
327.Sh "Top of Form Processing"
328.IX Xref "format, top of form top header"
329.IX Subsection "Top of Form Processing"
330Top-of-form processing is by default handled by a format with the
331same name as the current filehandle with \*(L"_TOP\*(R" concatenated to it.
332It's triggered at the top of each page. See \*(L"write\*(R" in perlfunc.
333.PP
334Examples:
335.PP
336.Vb 10
337\& # a report on the /etc/passwd file
338\& format STDOUT_TOP =
339\& Passwd File
340\& Name Login Office Uid Gid Home
341\& ------------------------------------------------------------------
342\& .
343\& format STDOUT =
344\& @<<<<<<<<<<<<<<<<<< @||||||| @<<<<<<@>>>> @>>>> @<<<<<<<<<<<<<<<<<
345\& $name, $login, $office,$uid,$gid, $home
346\& .
347.Ve
348.PP
349.Vb 29
350\& # a report from a bug report form
351\& format STDOUT_TOP =
352\& Bug Reports
353\& @<<<<<<<<<<<<<<<<<<<<<<< @||| @>>>>>>>>>>>>>>>>>>>>>>>
354\& $system, $%, $date
355\& ------------------------------------------------------------------
356\& .
357\& format STDOUT =
358\& Subject: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
359\& $subject
360\& Index: @<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
361\& $index, $description
362\& Priority: @<<<<<<<<<< Date: @<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
363\& $priority, $date, $description
364\& From: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
365\& $from, $description
366\& Assigned to: @<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
367\& $programmer, $description
368\& ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
369\& $description
370\& ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
371\& $description
372\& ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
373\& $description
374\& ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
375\& $description
376\& ~ ^<<<<<<<<<<<<<<<<<<<<<<<...
377\& $description
378\& .
379.Ve
380.PP
381It is possible to intermix \fIprint()\fRs with \fIwrite()\fRs on the same output
382channel, but you'll have to handle \f(CW\*(C`$\-\*(C'\fR (\f(CW$FORMAT_LINES_LEFT\fR)
383yourself.
384.Sh "Format Variables"
385.IX Xref "format variables format, variables"
386.IX Subsection "Format Variables"
387The current format name is stored in the variable \f(CW$~\fR (\f(CW$FORMAT_NAME\fR),
388and the current top of form format name is in \f(CW$^\fR (\f(CW$FORMAT_TOP_NAME\fR).
389The current output page number is stored in \f(CW$%\fR (\f(CW$FORMAT_PAGE_NUMBER\fR),
390and the number of lines on the page is in \f(CW$=\fR (\f(CW$FORMAT_LINES_PER_PAGE\fR).
391Whether to autoflush output on this handle is stored in \f(CW$|\fR
392(\f(CW$OUTPUT_AUTOFLUSH\fR). The string output before each top of page (except
393the first) is stored in \f(CW$^L\fR (\f(CW$FORMAT_FORMFEED\fR). These variables are
394set on a per-filehandle basis, so you'll need to \fIselect()\fR into a different
395one to affect them:
396.PP
397.Vb 4
398\& select((select(OUTF),
399\& $~ = "My_Other_Format",
400\& $^ = "My_Top_Format"
401\& )[0]);
402.Ve
403.PP
404Pretty ugly, eh? It's a common idiom though, so don't be too surprised
405when you see it. You can at least use a temporary variable to hold
406the previous filehandle: (this is a much better approach in general,
407because not only does legibility improve, you now have intermediary
408stage in the expression to single-step the debugger through):
409.PP
410.Vb 4
411\& $ofh = select(OUTF);
412\& $~ = "My_Other_Format";
413\& $^ = "My_Top_Format";
414\& select($ofh);
415.Ve
416.PP
417If you use the English module, you can even read the variable names:
418.PP
419.Vb 5
420\& use English '-no_match_vars';
421\& $ofh = select(OUTF);
422\& $FORMAT_NAME = "My_Other_Format";
423\& $FORMAT_TOP_NAME = "My_Top_Format";
424\& select($ofh);
425.Ve
426.PP
427But you still have those funny \fIselect()\fRs. So just use the FileHandle
428module. Now, you can access these special variables using lowercase
429method names instead:
430.PP
431.Vb 3
432\& use FileHandle;
433\& format_name OUTF "My_Other_Format";
434\& format_top_name OUTF "My_Top_Format";
435.Ve
436.PP
437Much better!
438.SH "NOTES"
439.IX Header "NOTES"
440Because the values line may contain arbitrary expressions (for at fields,
441not caret fields), you can farm out more sophisticated processing
442to other functions, like \fIsprintf()\fR or one of your own. For example:
443.PP
444.Vb 4
445\& format Ident =
446\& @<<<<<<<<<<<<<<<
447\& &commify($n)
448\& .
449.Ve
450.PP
451To get a real at or caret into the field, do this:
452.PP
453.Vb 4
454\& format Ident =
455\& I have an @ here.
456\& "@"
457\& .
458.Ve
459.PP
460To center a whole line of text, do something like this:
461.PP
462.Vb 4
463\& format Ident =
464\& @|||||||||||||||||||||||||||||||||||||||||||||||
465\& "Some text line"
466\& .
467.Ve
468.PP
469There is no builtin way to say \*(L"float this to the right hand side
470of the page, however wide it is.\*(R" You have to specify where it goes.
471The truly desperate can generate their own format on the fly, based
472on the current number of columns, and then \fIeval()\fR it:
473.PP
474.Vb 9
475\& $format = "format STDOUT = \en"
476\& . '^' . '<' x $cols . "\en"
477\& . '$entry' . "\en"
478\& . "\et^" . "<" x ($cols-8) . "~~\en"
479\& . '$entry' . "\en"
480\& . ".\en";
481\& print $format if $Debugging;
482\& eval $format;
483\& die $@ if $@;
484.Ve
485.PP
486Which would generate a format looking something like this:
487.PP
488.Vb 6
489\& format STDOUT =
490\& ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
491\& $entry
492\& ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
493\& $entry
494\& .
495.Ve
496.PP
497Here's a little program that's somewhat like \fIfmt\fR\|(1):
498.PP
499.Vb 3
500\& format =
501\& ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
502\& $_
503.Ve
504.PP
505.Vb 1
506\& .
507.Ve
508.PP
509.Vb 5
510\& $/ = '';
511\& while (<>) {
512\& s/\es*\en\es*/ /g;
513\& write;
514\& }
515.Ve
516.Sh "Footers"
517.IX Xref "format, footer footer"
518.IX Subsection "Footers"
519While \f(CW$FORMAT_TOP_NAME\fR contains the name of the current header format,
520there is no corresponding mechanism to automatically do the same thing
521for a footer. Not knowing how big a format is going to be until you
522evaluate it is one of the major problems. It's on the \s-1TODO\s0 list.
523.PP
524Here's one strategy: If you have a fixed-size footer, you can get footers
525by checking \f(CW$FORMAT_LINES_LEFT\fR before each \fIwrite()\fR and print the footer
526yourself if necessary.
527.PP
528Here's another strategy: Open a pipe to yourself, using \f(CW\*(C`open(MYSELF, "|\-")\*(C'\fR
529(see \*(L"\fIopen()\fR\*(R" in perlfunc) and always \fIwrite()\fR to \s-1MYSELF\s0 instead of \s-1STDOUT\s0.
530Have your child process massage its \s-1STDIN\s0 to rearrange headers and footers
531however you like. Not very convenient, but doable.
532.Sh "Accessing Formatting Internals"
533.IX Xref "format, internals"
534.IX Subsection "Accessing Formatting Internals"
535For low-level access to the formatting mechanism. you may use \fIformline()\fR
536and access \f(CW$^A\fR (the \f(CW$ACCUMULATOR\fR variable) directly.
537.PP
538For example:
539.PP
540.Vb 3
541\& $str = formline <<'END', 1,2,3;
542\& @<<< @||| @>>>
543\& END
544.Ve
545.PP
546.Vb 1
547\& print "Wow, I just stored `$^A' in the accumulator!\en";
548.Ve
549.PP
550Or to make an \fIswrite()\fR subroutine, which is to \fIwrite()\fR what \fIsprintf()\fR
551is to \fIprintf()\fR, do this:
552.PP
553.Vb 8
554\& use Carp;
555\& sub swrite {
556\& croak "usage: swrite PICTURE ARGS" unless @_;
557\& my $format = shift;
558\& $^A = "";
559\& formline($format,@_);
560\& return $^A;
561\& }
562.Ve
563.PP
564.Vb 5
565\& $string = swrite(<<'END', 1, 2, 3);
566\& Check me out
567\& @<<< @||| @>>>
568\& END
569\& print $string;
570.Ve
571.SH "WARNINGS"
572.IX Header "WARNINGS"
573The lone dot that ends a format can also prematurely end a mail
574message passing through a misconfigured Internet mailer (and based on
575experience, such misconfiguration is the rule, not the exception). So
576when sending format code through mail, you should indent it so that
577the format-ending dot is not on the left margin; this will prevent
578\&\s-1SMTP\s0 cutoff.
579.PP
580Lexical variables (declared with \*(L"my\*(R") are not visible within a
581format unless the format is declared within the scope of the lexical
582variable. (They weren't visible at all before version 5.001.)
583.PP
584Formats are the only part of Perl that unconditionally use information
585from a program's locale; if a program's environment specifies an
586\&\s-1LC_NUMERIC\s0 locale, it is always used to specify the decimal point
587character in formatted output. Perl ignores all other aspects of locale
588handling unless the \f(CW\*(C`use locale\*(C'\fR pragma is in effect. Formatted output
589cannot be controlled by \f(CW\*(C`use locale\*(C'\fR because the pragma is tied to the
590block structure of the program, and, for historical reasons, formats
591exist outside that block structure. See perllocale for further
592discussion of locale handling.
593.PP
594Within strings that are to be displayed in a fixed length text field,
595each control character is substituted by a space. (But remember the
596special meaning of \f(CW\*(C`\er\*(C'\fR when using fill mode.) This is done to avoid
597misalignment when control characters \*(L"disappear\*(R" on some output media.