Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

Comment on printing multiple pages
Download Code
Re: printing multiple pages
by Preceptor (Chaplain) 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' ?
Re: printing multiple pages
by choroba (Abbot) 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.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1069372]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2014-07-24 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (157 votes), past polls