On Aug 20, 3:10 pm, [EMAIL PROTECTED] (Mathew Snyder) wrote:
> I run a script which creates a small report for different users of a system we
> have here at work.  The report is a simple text document formated with, of all
> things, the format function.  It uses a TOP to create a header for each of our
> customers which a user has worked with.  For some reason the first and only 
> the
> first write of the TOP results in a double write.  

>             write TIMESHEET_TOP;

<snip>

>                     write TIMESHEET;

> It gets that double header.  Again, everything else gets only the one, 
> expected,
> header.  Anyone have any ideas as to why the first one always prints twice?

Because Perl is smarter than you're giving it credit for. :-P

$ perldoc -f write
     write FILEHANDLE
     write EXPR
     write
             Top of form processing is handled automatically:  if
             there is insufficient room on the current page for
             the formatted record, the page is advanced by
             writing a form feed, a special top-of-page format is
             used to format the new page header, and then the
             record is written.

Key phrase there: "top of form processing is handled automatically".
That is, you don't have to write the header your self.  Perl does that
for you, on each new page the report is printed to.  You just define
the format header.  Let Perl decide when it needs to be written.

Remove the write TIMESHEET_TOP line.

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to