Hello,

How about something like the following.  It is designed to read in from a
file with one filename per line, open the input file and the output file
(best to create a new file than clobber the original), print the header to
the output file, then print each line of the input file into the output
file.

while(<>) {
        chomp;
        open(IN,$_);
        open(OUT,">$_.mod");

        print OUT "################first line of header
block#############\n";
        print OUT "################second line of header
block#############\n";
        print OUT "################third line of header
block#############3\n";
        print OUT "################etc etc etc #############3\n";

        while(<IN>) {
                print OUT $_;    #  Since no chomp, no need for \n
        }

        close(OUT);
        close(IN);
}

Cheers,

Keith Miller - Performance Engineer
AT&T Wireless - WNS - WNE
[EMAIL PROTECTED]




-----Original Message-----
From: Tanya Graham [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 21, 2001 4:55 PM
To: '[EMAIL PROTECTED]';
'[EMAIL PROTECTED]'
Subject: file manipulation


Hi, 
I need to be able to open up a bunch of files and add a chunk of text to the
beginning of each one.  More specifically, I have a bunch (75,000+) of
source files, and I need to add a big comment that has our copyright
information at the top of each one.  I've found information on deleting and
renaming files, but not inserting into them. Any Ideas?
Thanks
Tanya Graham
Veeco Metrology
Tucson, AZ
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to