Hi Bob Thanks for the help. I renamed the format label from ADDRESSLABEL to SUMMARY and it appeared to work also. Thanks again for the help. Tony
-----Original Message----- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: 16 April 2002 19:36 To: [EMAIL PROTECTED] Subject: Re: Writing formatted results to a file On Tuesday, April 16, 2002, at 10:11 AM, Ho, Tony wrote: > 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; > } > } > in addition you need to quote the format label when assigning: $~ = 'ADDRESSLABEL'; > 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 > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]