 #this perlscript changes the lables :PROJ :VERS :PATH  :MAKE in the projectfile
 #the old projectfile is renamed to *_bak
 #call: perl project version path profectfile
 #17.08.99 Thomas Roesner


 $newproj = shift;                      # new project from @ARGV
 $newvers = shift;                      # new version from @ARGV
 $newpath = shift;                      # new workpath from @ARGV
 $newmake = shift;                      # new makefile 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
   {
     $proj += s/:PROJ.*/:PROJ $newproj/;        # replace
     $vers += s/:VERS.*/:VERS $newvers/;        # replace
     $path += s/:PATH.*/:PATH $newpath/;        # replace
     $make += s/:MAKE.*/:MAKE $newmake/;        # replace

     print O;                           # copy to outfile
   }
   $text = ":".PROJ." ".$newproj."\n";
   print O $text unless $proj;          # append if no replacements
   $text = ":".VERS." ".$newvers."\n";
   print O $text unless $vers;          # append if no replacements
   $text = ":".PATH." ".$newpath."\n";
   print O $text unless $path;          # append if no replacements
   $text = ":".MAKE." ".$newmake."\n";
   print O $text unless $make;          # append if no replacements
   close O; close I;                    # close files
}
