formats/end-of-page 
Author Message
 formats/end-of-page

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)

Thanks!

Rudy
University of Pittsburgh
Pittsburgh PA



Wed, 30 Mar 1994 05:41:14 GMT  
 formats/end-of-page
: 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



Sat, 02 Apr 1994 09:01:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. **FORMAT Formatting columns/pages

2. __END__ comment confusing in man-page-in-perl-script

3. need blanks at end of format line

4. Putting \r\n at end of lines using format and write

5. activestate perl kernel32.dll page fault at program end

6. variables in top-of-page formats

7. Forcing format to print top of page

8. Perl man pages in .CHM format?

9. Top-of-page format: STDOUT_TOP??

10. Need timed routine to format shtml pages from cgi on server to htm content

11. long records, page breaks in formats

12. Alt format for man pages?

 

 
Powered by phpBB® Forum Software