Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

printing multiple pages

by hvn52 (Initiate)
on Jan 05, 2014 at 09:54 UTC ( #1069372=perlquestion: print w/replies, xml ) Need Help??
hvn52 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I've written a script that gets info from MySQL and prints it directly to paper. It works fine (for years), with 1 issue: after the last printed line I have to use print $LPR "\f";, so it starts printing on the next sheet. However, it also causes an unnecessary empty feed after the last sheet is printed. Is there a way that I can prevent those empty last feeds? Thanks

Replies are listed 'Best First'.
Re: printing multiple pages
by choroba (Bishop) on Jan 05, 2014 at 11:07 UTC
    Print the feed character before every page except the first one:
    my $first = 1; until (0 == int rand 10) { # The number of pages is unknown in advanc +e. print "\f" if ! $first; undef $first; print "page...\n"; }
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thank for your response. What use is it to print it before every page ?
        Before every page except the first one is the same as after each page except the last one, which is what I understood you had requested.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: printing multiple pages
by Preceptor (Deacon) on Jan 05, 2014 at 10:44 UTC

    A code example might help. It sounds like you're doing a loop where you're printing some stuff, printing linefeed, repeat?

    Sounds like you 'simply' need to check if you printed any text on the last loop. Maybe by appending '\f' to your text as you print?

    Hard to be more specific without a clearer idea of what you're aiming for, and doing already.

      Hi, Thanks for responding. I'm using a loop to walk through either once or x times, depending on the number of sheets to print. At the end of this loop, there's the '\f'. I've put it there because there are empty lines left until the end of the page. Would you recommend to use  print "\n * (number of lines left)"; instead of '\f' ?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1069372]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-05-24 04:57 GMT
Find Nodes?
    Voting Booth?