OSDN Git Service

[Release] Ver.2.1.1
[dokopop/dokopop.git] / change_iss.pl
1 #!perl
2 # Change the string in the .iss file.
3
4 sub usage
5 {
6 print << "EOT";
7 Usage:
8   change_iss.pl [input filename] [section name] [key name] [substituted value]
9 EOT
10 }
11
12 $u_input = $ARGV[0];
13 $u_section = $ARGV[1];
14 $u_key = $ARGV[2];
15 $u_value = $ARGV[3];
16
17 if (!$u_value){
18         usage();
19         exit(1);
20 }
21
22 open F,$u_input or die "open error $u_input";
23
24 while (<F>){
25         if (length>0){
26                 if (/^\[(.+)\]/){
27                         # Section start
28                         $section = $1;
29                         $key = '';
30                 } else {
31                         if (/^(.+?)=/){
32                                 # Found a key.
33                                 $key = $1;
34                                 if ($u_section =~ /^$section$/i){
35                                         # found the same section
36                                         if ($u_key =~ /^$key$/i){
37                                                 $_ = "$key=$u_value\n";
38                                         }
39                                 }
40                         }
41                 }
42         }
43         print $_;
44 }
45
46