Hi guys
I was wondering if you could help me.
Does anybody know how to write formatted results to a file ?
I am getting the following error :
write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785,
<SUMMARYTMP> line 5.
write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785,
<SUMMARYTMP> line 15.
write() on closed filehandle main::ADDRESSLABEL at ./test.pl line 2785,
<SUMMARYTMP> line 21.
This is the section of my perl code reads results from an BCP output file
and is as follows :
sub create_summary_report
{
my (@record, $element, $rows_copied, $line_output);
@record = qw(A B C);
$rows_copied = "rows copied";
$element = 0;
open SUMMARYTMP, "<$bcp_file_directory$log_file_summary_tmp"
or die "Unable to open $log_file_summary_tmp for reading: $!\n";
open SUMMARY, ">$log_directory$log_file_summary_final"
or die "Unable to open $log_file_summary_final for writing: $!\n";
print SUMMARY "Summary Details\n";
print SUMMARY "--------------------------\n";
print SUMMARY "Account (From) : $fromAccount\n";
print SUMMARY "Account (To) : $toAccount\n\n\n";
print SUMMARY "Record Types\n";
print SUMMARY "------------\n";
format ADDRESSLABEL =
@<<<<<, @<<<<<
$record[$element], $line_output
..
while(<SUMMARYTMP>) {
chop;
$line_output = $_;
if ($line_output =~ /\b$rows_copied\b/) {
print SUMMARY write(ADDRESSLABEL);
$element = $element + 1;
}
}
close SUMMARYTMP
or die "Error closing $log_file_summary_tmp";
close SUMMARY
or die "Error closing $log_file_summary_final";
}
I would be most grateful with any advice.
Thanks in advance
Tony