Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append to a file

Status
Not open for further replies.

preethib

Programmer
Jul 20, 2000
39
IN
Hi teks,

I am trying to copy many log files to a single log file. Is there a good way in perl to do it.

thanks,

preethib@yahoo.com
 
One way is to open the files, read the contents, and write them to another file. Here's an example:
Code:
@filelist = ("file1", "file2", "file3");
$newfile = "newfile";
open(NF, ">$newfile") or die "Can't open $newfile: $! \n";
foreach $file (@filelist) {
    open(F, "$file") or die "Can't open $file: $! \n";
    @Info = (<F>);
    close(F);
    print NF &quot;@Info&quot;;
}
close(NF);
 
Here's another way, for unix systems:
Code:
system(&quot;cat filename filename2 filename3 >resultfile&quot;);
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top