$report = generate_report($foo); open(FILE, ">>report.txt") or die "blah!"; print FILE "Report number: $i"; $i++; # # three lines to format header nicely # @report_lines = split(/\n/, $report); print FILE $report_lines[0]; print FILE $report_lines[1]; print FILE $report_lines[2]; print FILE $report_lines[3]; print FILE $report_lines[4]; close FILE or die "blergh!"; # skip a few $report = generate_report($bar); open(FILE, ">>report.txt") or die "blah!"; print FILE "Report number: $i"; $i++; # # format the header again # @report_lines = split(/\n/, $report); print FILE $report_lines[0]; # you see where this is going