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