README.md edited online with Bitbucket
[swg-src.git] / dsrc / sku.0 / sys.server / compiled / game / datatables / npc_lair / dan_pie.pl
blob9bb889a47a522c9ff3d88c1e6a177af25f581103
1 # get the list of files to process from renames.rsp
2 open(RSP, "pie.rsp");
4 $changedCount = 0;
5 $unchangedCount = 0;
6 $substitutions = 0;
8 # process all the files
9 while (<RSP>)
11 # get rid of the freakin' newline
12 chomp;
14 # provide status
15 print "processing " . $_;
17 # open the files for i/o
18 $file = $_;
19 $new = $file . ".new";
20 open(IN, $file);
21 open(OUT, ">" . $new);
23 # process all the lines in the input file
24 $changed = 0;
25 while (<IN>)
27 # keep around the original line so we can check if it has been changed
28 $save = $_;
30 # apply the transformations
31 s/\.tpf/.iff/g;
33 # update the changed flag
34 if ($save ne $_)
36 $changed = 1;
37 $substitutions += 1;
40 # emit the [possibly] changed line
41 print OUT;
44 # done accessing the contents of the files
45 close(IN);
46 close(OUT);
48 if ($changed == 1)
50 $changedCount += 1;
52 # check the file out and replace its contents
53 system("p4 edit " . $file);
54 unlink($file);
55 rename($new, $file);
57 # provide results
58 print " [changed]\n";
61 else
63 $unchangedCount += 1;
65 # remove temporary work
66 unlink($new);
68 # provide results
69 print " [unchanged]\n";
73 close(RSP);
75 print $changedCount . " changed files, " . $unchangedCount . " unchanged files, " . $substitutions . " substitutions\n";