1 |
root |
1.1 |
#!/usr/bin/perl |
2 |
|
|
$TYPE = $ARGV[0]; |
3 |
|
|
die ("type is 0: $TYPE\n") if (($TYPE + 1) == 1); |
4 |
|
|
|
5 |
|
|
for ($i=1; $i<=$#ARGV; $i++) { |
6 |
|
|
if (!rename("$ARGV[$i]", "$ARGV[$i].bak")) { |
7 |
|
|
print STDERR "Unable to rename file $ARGV[$i]\n"; |
8 |
|
|
next; |
9 |
|
|
} |
10 |
|
|
open(IN,"<$ARGV[$i].bak"); |
11 |
|
|
open(OUT,">$ARGV[$i]"); |
12 |
|
|
while (<IN>) { |
13 |
|
|
$in = $_; |
14 |
|
|
if (/^end\s*$/) { |
15 |
|
|
print OUT "name_pl $namepl\n"; |
16 |
|
|
print OUT "client_type $TYPE\n"; |
17 |
|
|
$namepl=""; |
18 |
|
|
} |
19 |
|
|
if (/^Object (.*)$/) { |
20 |
|
|
$namepl = $1."s"; |
21 |
|
|
} |
22 |
|
|
if (/^name (.*)$/) { |
23 |
|
|
$namepl = $1."s"; |
24 |
|
|
} |
25 |
|
|
print OUT $in; |
26 |
|
|
} |
27 |
|
|
close(OUT); |
28 |
|
|
close(IN); |
29 |
|
|
unlink("$ARGV[$i].bak"); |
30 |
|
|
} |