Contents /
Previous /
Next
Formats
(More info:I)
Formats are defined as follows:
format [NAME] =
FORMLIST
.
FORMLIST pictures the lines, and contains the arguments which will
give values to the fields in the lines. NAME defaults to
STDOUT if omitted.
Picture fields are:
| @<<<... |
left adjusted field, repeat the < to denote the desired width |
| @>>>... |
right adjusted field |
| @|||... |
centered field |
| @#.##... |
numeric format with implied decimal point |
| @* |
a multi-line field |
Use ^ instead of @ for multiline block filling.
Use ~ at the beginning of a line to suppress unwanted empty lines.
Use ~~ at the beginning of a line to have this format line repeated until
all fields are exhausted.
Use $- to zero to force a page break on the next write.
- formline PICTURE, LIST
- Formats LIST according to PICTURE
and accumulates the result into $^A.
- write [ FILEHANDLE ]
- Writes a formatted record to the specified file, using the format associated
with that file (same name).
Example:
$me = "fred";
$you = "Mary";
format LETTER =
Dear @<<<<,
$you;
I am very sorry, but I cannot help
you with your problem.
Sincerely,
@<<<<<
$me
.
open LETTER , ">letter.txt";
write ( LETTER );
close LETTER;
Output:
Dear Mary ,
I am very sorry, but I cannot help
you with your problem.
Sincerely,
fred