blob: 38bbe80dc431bc9ffa7caee85f79c73ebef66867 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#! /usr/bin/perl
my @args=@ARGV;
my @configoptions;
my @configvalues;
my @common;
my $configcounter = 0;
# first, read the 1st file
open (FILE,"$args[0]") || die "Could not open $args[0]";
while (<FILE>) {
my $str = $_;
if (/\# ([\w]+) is not set/) {
$configoptions[$configcounter] = $1;
$configvalues[$configcounter] = $str;
$common[$configcounter] = 1;
$configcounter ++;
} else {
if (/([\w]+)=/) {
$configoptions[$configcounter] = $1;
$configvalues[$configcounter] = $str;
$common[$configcounter] = 1;
$configcounter ++;
} else {
$configoptions[$configcounter] = "foobarbar";
$configvalues[$configcounter] = $str;
$common[$configcounter] = 1;
$configcounter ++;
}
}
};
# now, read all configfiles and see of the options match the initial one.
# if not, mark it not common
my $cntr=1;
while ($cntr < @ARGV) {
open (FILE,$args[$cntr]) || die "Could not open $args[$cntr]";
while (<FILE>) {
my $nooutput;
my $counter;
my $configname;
if (/\# ([\w]+) is not set/) {
$configname = $1;
} else {
if (/([\w]+)=/) {
$configname = $1;
}
}
$counter = 0;
$nooutput = 0;
while ($counter < $configcounter) {
if ("$configname" eq "$configoptions[$counter]") {
if ("$_" eq "$configvalues[$counter]") {
1;
} else {
$common[$counter] = 0;
}
}
$counter++;
}
}
$cntr++;
}
# now print the common values
my $counter = 0;
while ($counter < $configcounter) {
if ($common[$counter]!=0) {
print "$configvalues[$counter]";
}
$counter++;
}
1;
|