forked from qos-ch/logback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.pl
44 lines (33 loc) · 766 Bytes
/
version.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
if ($#ARGV < 1) {
print "Usage: version.pl VER FILE {FILE, FILE}\n";
exit;
}
$V= $ARGV[0];
print "VER:$V\r\n";
shift(@ARGV);
sub replace () {
my $filename = $_[0];
if(-s $filename) {
print "Processing [" . $filename . "]\r\n";
my $origFile = "$filename.original";
rename($filename, $origFile);
open(OUT, ">$filename");
open(IN, "$origFile");
my $hitCount=0;
while(<IN>) {
if($hitCount == 0 && /<version>.*<\/version>/) {
s/<version>.*<\/version>/<version>$V<\/version>/;
$hitCount++;
}
print OUT;
}
close(IN);
close(OUT);
unlink($origFile);
} else {
print "File [" . $filename . "] does not exist\r\n"
}
}
foreach $ARG (@ARGV) {
do replace($ARG);
}