develooper Front page | perl.beginners | Postings from January 2002

appending to a file

Thread Next
Craig Williams
January 15, 2002 14:43
appending to a file
Message ID:
I'm probably missing something obvious here, but heck it's a beginners list.

the first time the log file is generated it contains the correct data.
However any time it tries appending data to the existing log file, nothing
gets written to it.  Any help is appreciated.

#gather log data
open (FH, "<$emailBody") || die "could not open file: $!";
# $emailBody contains the log information
my @logContents = <FH>;
close (FH);
#append to log file
open (FH, ">>$outfile") || die "could not open file: $!";
#$outfile is a file name/path
seek FH,0,2; 
foreach my $logContents(@logContents){
	print FH "$logContents";

close (FH);

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About