 #this perlscript adds a new file to the projectfile
 #the old projectfile is renamed to *_bak
 #call: perl newfile profectfile
 #17.08.99 Thomas Roesner


 $newfile = shift;                      # old text from @ARGV

 while($f = shift){                     # get each name from @ARGV

   print "Perl is changing the file ".$f."\n";
                                                                                                                                                               
   unlink ($f.'_bak');                  # deletes old backup
   rename ($f,$f.'_bak');               # and creates a new one

   open(I,$f.'_bak') || die;            # open the old file
   open(O,">".$f) || die;               # open the new file
   $n = 0;                              # zero counter
   while(<I>)                           # read from input
   {
     $n += /$newfile/;
     print O;                           # copy to outfile
   }
   print O $newfile."\n" unless $n;     # append if no replacements
   close O; close I;                    # close files
}
