--- Craig Williams <[EMAIL PROTECTED]> wrote:
> 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);
Why are you doing a seek on a filehandle opened in append mode? You appear to be
trying to seek
to the end of the file, but that is already done for you. Also, since you didn't chomp
@logContents, you can take advantage of the fact that print takes an array:
open FHIN, "<$emailBody" or die "could not open $emailBody for reading: $!";
open FHOUT, ">>$outfile" or die "could not open $outfile for appending: $!";
print FHOUT <FHIN>;
close FHOUT;
close FHINT;
Cheers,
Curtis "Ovid" Poe
=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]