Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks
I have recently used perl reports for the first time with much success and enjoyment. However, my report creates a new heading for every page? I'm both not sure why that is and know how to prevent it from reocurring. Here is my code.
sub setup_report { my ($count, $email_count, @reports) = @_; $| = 1; my $surname = my $givenName = my $ticket_id = my $support_id = my +$date = my $email = ''; my $file = "QA_Report_" . strftime('%m-%d-%Y', localtime) . ".txt" +; chdir "../reports/" or die "cannot chdir reports $!\n"; open(OUTF, ">$file") or die $!; select(OUTF); format OUTF_TOP = QA Report @<<<<<<< $date Total Count: @<<<<< Email Count: @<<<<< $count, $email_count Name TicketID SupportID Email ------------------------------------------------------------------ . $date = strftime('%m-%d-%y', localtime); write; format OUTF = @<<<<<<<<<< @<<<<<<< @|||||||||| @<<<<<<<< @<<<<<<<< +<<<<<<<<< $givenName, $surname, $ticket_id, $support_id, $email . foreach my $report (@reports){ $givenName = $$report[0] || ""; $surname = $$report[1] || ""; $ticket_id = $$report[2] || ""; $support_id = $$report[3] || ""; $email = $$report[4] || ""; write;} close OUTF;}

Replies are listed 'Best First'.
Re: creating reports without reoccuring heading
by antirice (Priest) on Aug 04, 2003 at 19:38 UTC

    Your top seems to be 6 lines long. The subsequent number of lines seems to be determined by @reports. Thus if you put $= = 6 + @reports + 2; (extra 2 for good luck) after your select, everything should print as expected. For more information on $= (format lines per page variable) check out perldoc perlvar.

    Hope this helps.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Re: creating reports without reoccuring heading
by LordWeber (Monk) on Aug 04, 2003 at 19:39 UTC
    Re: creating reports without reoccuring heading
    by elbow (Scribe) on Aug 05, 2003 at 07:35 UTC
      It sounds like you're asking why the heading is displayed at the top of each page. If so, your OUTF_TOP format is automatically used at the top of each page.

      I'm not sure if you can stop it from printing a header after the first page, but you can change the top of page header to reduce the number of lines printed. I've not used this myself but it is detailed in O'Reillys Programming Perl p 237/238.

      The only other thing I can think of is don't use OUTF_TOP. Set up an alternate name for your header and write that before writing the rest of the report.

      elbow
    Re: creating reports without reoccuring heading
    by caliban (Novice) on Aug 05, 2003 at 12:25 UTC
      The easiest way that occurs to me is to set the report header to blank after the first header has been printed, ie.
      foreach my $report (@reports){ $givenName = $$report[0] || ""; $surname = $$report[1] || ""; $ticket_id = $$report[2] || ""; $support_id = $$report[3] || ""; $email = $$report[4] || ""; write; format OUTF_TOP = . }