11.5 The Top-of-Page FormatMany reports end up on some hardcopy device, like a printer. Printer paper is generally clipped into page-size chunks, because most of us stopped reading paper in scrolls a long time ago. So the text being fed to a printer typically has to take page boundaries into consideration by putting in blank lines or formfeed characters to skip across the perforations. Now, you could take the output of a Perl program and feed it through some utility (maybe even one written in Perl) that does this pagination, but there's an easier way.
Perl allows you to define a
top-of-page format that triggers a page-processing mode. Perl counts each line of output generated by any format invocation to a particular filehandle. When the next format output cannot fit on the remainder of the current page, Perl spits out a
formfeed followed by an automatic invocation of the top-of-page format, and finally the text from the invoked format. That way, the result of one
The top-of-page format is defined just like any other format. The default name of a top-of-page format for a particular filehandle is the name of the filehandle followed by
Perl defines the variable format ADDRESSLABEL_TOP = My Addresses -- Page @< $% . The default page length is 60 lines. You can change this by setting a special variable, described shortly.
Perl doesn't notice whether you also
|
|