: Perl prints the form-feed character at the end of a page using formatted
: output.
:
: Reports sent to the printer include spurious blank pages when the
: form-feed comes at the end of a full page of text.
:
: The form-feed problem can be hacked away by:
: (1) $= = 32767; # or some other large number
: but then the top-of-page header appears just once, or
:
: (2) $= -= 1;
: but you lose a line per page.
:
: I can use (2) for now, but is there a better solution (like some way to
: tell perl to omit the form-feed)?
:
: This is a general problem, but:
: perl: [DOS] V4.010
: machine: PS/2 Model 70
: OS: DOS V3.3
: printer: HP LaserJet III (advanced)
I'd say the auto-pagination feature of your printer is busted. It
shouldn't go to the next page unless there's something to write on it.
Looked at another way, it should eat the form feed when it coincides
with its own form feed. There may be some sequence you can send to the
printer to disable this misfeature.
In the absence of that, there are several ways to go. First, if you know
the size of the record you're writing, you can check against $- yourself
and see if it's going to come out even. If it does, add $= to $-, write
the record, dump out the header yourself, and keep going.
Alternately, you can postprocess the output before sending it to the
printer. Instead of
open(LPR, ">/dev/lpr"); # or whatever
...
write LPR;
you could do
if (open(LPR, "|-") == 0) {
open(REALLPR, ">/dev/lpr"); # or whatever
$/ = "\f";
while (<STDIN>) {
$lines = ($_ =~ tr/\n/\n/);
if ($lines == $MAXLINES) {
chop;
}
print REALLPR;
}
exit;
}
...
write LPR;
If you want to delete all form feeds, it's a simple matter to pipe through
tr -d. Even if you want to write to STDOUT, you can substitute in a pipe
like this:
open(STDOUT,"|-") || exec 'tr', '-d', '\014';
...
write;
(This may take a recent version to work right.)
Larry