Footers
While $^ ($FORMAT_TOP_NAME) contains the name of the current header format, there is
no corresponding mechanism to do the same thing automatically for a
footer. Not knowing how big a format is going to be until you evaluate
it is one of the major problems. It’s on the to-do list.[232]
Here’s one strategy: if you have a fixed-size footer, you can get
footers by checking $– ($FORMAT_LINES_LEFT) before each write, and then print the footer yourself if
necessary.
Here’s another strategy: open a pipe to yourself using open(MESELF, "|–") (see the open entry in Chapter 27),
and always write to MESELF instead of STDOUT. Have your child process postprocess
its STDIN to rearrange headers and
footers however you like. Not very convenient, but it’s doable.
[232] That doesn’t guarantee we’ll ever do it, of course. Formats are somewhat passé in this age of WWW, Unicode, XML, XSLT, and whatever the next few things after that are.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access