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

appending to a file

Thread Next
From:
Craig Williams
Date:
January 15, 2002 14:43
Subject:
appending to a file
Message ID:
E94E9A31F8EDD311BA4B00508B6493BB524534@epsnt1.epshq.eps.rwk.com
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About