File SAPconf-reconfig of Package sapconf.4964
#!/usr/bin/perl
use strict;
use warnings;
if (! $ARGV[0] || ! $ARGV[1])
{
print <<EOF;
$0 usage: <file1> <file2>
Little script to compare values of parameters of two different files. Integer
values, that are higher in one of the files, always win.
Prints the result to STDOUT
EOF
exit 1;
}
my @file2_ar;
open FILE, $ARGV[1] or die "Couldn't open file $ARGV[1] for reading";
while (<FILE>)
{
my $line = $_; chomp $line;
push (@file2_ar, $line);
}
close FILE;
open FILE, $ARGV[0] or die "Couldn't open file $ARGV[0] for reading";
while (<FILE>)
{
my $line = $_; chomp $line;
$line =~ /^\s*([a-zA-Z0-9_]+)=(\"?\D*(\d+)\"?\s*)$/;
my $param_file1 = $1;
my $value_file1 = $3;
for (my $count = 0; $count < @file2_ar; $count++ )
{
$file2_ar[$count] =~ /^\s*([a-zA-Z0-9_]+)=(\"?\D*(\d+)\"?\s*)$/;
my $param_file2 = $1;
my $value_file2 = $3;
if (defined $param_file1 and defined $param_file2
and defined $value_file1 and defined $value_file2
and $param_file1 eq $param_file2
and $value_file2 > $value_file1)
{
$line = $file2_ar[$count];
splice(@file2_ar,$count,1);
last;
}
}
print "$line\n";
}
close FILE;