Hi,
I am trying to write out multiple report files using perl. Each file has the same structure, but with different data. So, my basic code looks something like
#begin code
our $log_fh;
open %log_fh, ">" . $logfile
our $rep;
if (multipleReports)
{
while (@reports) {
printReport($report[0]);
}
}
sub printReports
{
open $rep, ">" . $[0];
printHeaders();
printBody();
close $rep;
}
sub printHeader() {
format HDR =
@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$generatedLine
.
format HDR_TOP =
.
$rep->format_name("HDR");
$rep->format_top_name("HDR_TOP");
$generatedLine = "test";
write($rep);
$generatedLine = "next item";
write($rep);
$generatedLine = "last header item";
write($rep);
}
sub printBody #There are multiple such sections in my code. For simplicity, I have just shown 1 here
{
#declare own header and header top. Set report to use these and print items to $rep
}
#end code
The above is just a high level of the code I am using and I hope I have captured all the salient points. However, for some reason, I get the first report file output correctly. The second file instead of having in the first section
test
next item
last item
reads
last item
last item
last item
I have tried a whole lot of options primarily around autoflush, but, for the life of me can't figure out why it is doing this. I am using Perl 5.8.2. Any help/pointers much appreciated.
Thanks
George