More About the Fieldholders
So far, by example, you know that the fieldholder
@<<<<
indicates a 5-character,
left-justified field and that
@<<<<<<<<<<
indicates an 11-character, left-justified field. Here’s the
whole scoop, as promised earlier.
Text Fields
Most fieldholders start with
@
. The characters
following the @
indicate the type of field, while
the number of characters (including the @
)
indicates the field width.
If the characters following the @
are
left-angle brackets
(<<<<
), you get a left-justified
field; that is, the value will be padded on the right with spaces if
the value is shorter than the field width. (If a value is too long,
it’s truncated automatically; the layout of the format is
always preserved.)
If the characters following the @
are
right-angle brackets
(>>>>
), you get a right-justified
field—that is, if the value is too short, the field gets padded
on the left with spaces.
Finally, if the characters following the @
are
vertical bars
(||||
), you get a centered field; if the value is
too short, the field gets padded on both sides with spaces, enough on
each side to make the value mostly centered within the field.
Numeric Fields
Another kind of fieldholder is a
fixed-precision numeric field, useful for those big financial
reports. This field also begins with @
, and is
followed by one or more
#
’s with
an optional dot (indicating a decimal point). Once again, the
@
counts as one of the characters of the field.
For example:
format MONEY = Assets: @#####.## Liabilities: ...
Get Learning Perl on Win32 Systems now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.