Sorry for not explaining better. See commments below.
-----Original Message----- From: Mat Harris [mailto:[EMAIL PROTECTED]] Sent: Monday, October 07, 2002 7:24 AM To: Timothy Johnson Cc: 'Steve'; [EMAIL PROTECTED] Subject: Re: File::Copy question if you want to append to a second file then you should use ">>" when opening, not ">" or you will delete the text already there. if it was just a typo then ignore me. On Mon, Oct 07, 2002 at 07:20:29 -0700, Timothy Johnson wrote: > > If you want to append the contents of one file to another, then you will > have to open both files, read the first one, and write it to the second one. > Something like this should work: > > ###################### > > use strict; > use warnings; > ##Here I open the logfile for reading and the archive file for appending > open(LOG,"mylog.log") || die "Couldn't open logfile for reading!"; > open(ARCHIVE,">>archive.log") || die "Couldn't open the archive file for > appending!"; > ##Here I read the contents of the logfile and print them directly to the archive > while(<LOG>){ > print ARCHIVE $_; > } > ##Once I'm done, I reopen the logfile using the > operator to truncate it so that ##I'm not appending the same data next time, then close both files > open(LOG,">mylog.log") || die "Couldn't truncate logfile!"; > close LOG; > close ARCHIVE; > > ####################### > > > > -----Original Message----- > From: Steve [mailto:[EMAIL PROTECTED]] > Sent: Monday, October 07, 2002 6:46 AM > To: [EMAIL PROTECTED] > Subject: File::Copy question > > > I am using Windows 98 and ActiveState Perl. I have a log file that after a > certain size is truncated and reused. I have written a simple script to > copy that file to another file using File::Copy. Is there a way to make > sure the second file is appended instead of overwritten, using File::Copy > or do I need to use something else? > > > ----- > > The three most dangerous things are a programmer with a soldering iron, a > manager who codes, and a user who gets ideas. > > ---- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Mat Harris OpenGPG Public Key ID: C37D57D9 [EMAIL PROTECTED] matthewh.genestate.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]